Skip to main content

Build multi-cloud & hybrid networks

· 7 min read
Ayyaz Akhtar
Engineer @ Disney

cover

Goals

The purpose of this guide is to create four distributed networks and combine them into one highly available logically connected network.

  • Build with the top three cloud vendors (aws.amazon.com, azure.microsoft.com, cloud.google.com) and one On-Premise (pfsense.org) network
  • Scale Mesh network topology to allow additional point-to-point connections
  • Dynamic routing between Autonomous Systems (AS) using Border Gateway Protocol (BGP)
  • Encrypt network traversal over Virtual Private Network (VPN) tunnels using Internet Protocol Security (IPSec)
AWSAzureCGPPFSense
NetworkVNETVPCVLAN
GatewayVWANNCCISP
DNSPrivate ResolverCloud DNSPihole
S2SConnectionPeer VPNIPSec
SSMAzure vmGCP vmMac

Network

4 Network

  • Final mesh network topology architecture

AWS

AWS

Network

VPC

  • Create a Virtual Private Cloud Network in AWS

VPC config-a

VPC config-b

Resource to CreateVPC and more
Namevpc-aws
IPv4 CIDR block172.16.11.0/24
Num of AZs2
Public0
Private2
NATNone
EndpointNone

Gateway

Gateway

  • Identify the IP address of the ISP
  • Point to Point Identification and traffic passthrough

Customer Gateway

Customer Gateway

Namepfsense
BGP ASN65000
IP address4.4.4.4

Transit Gateway

Transit Gateway config-a

Transit Gateway config-b

Nametg-aws
Descriptiontg-aws
ASN64512

Route Table

Update Route Table

  • Update routes to TGW

DNS

DNS

  • AWS will dedicate a reserved IP address x.x.x.2 for a VPC resolver
  • Outbound Endpoints will allow you to forward DNS requests for resolvers on other networks
  • Inbound Endpoints will allow resolvers on other networks to forward requests to AWS

Outbound Endpoint

Outbound Endpoint config-a

Outbound Endpoint config-b

Outbound Endpoint config-c

Outbound Endpoint config-d

Endpoint Nameoe-aws
VPCvpc-aws-vpc
Security GroupDefault
Endpoint TypeIPv4
IP Address #1AZ us-east-1, subnet 1, IPv4
IP Address #2AZ us-east-2, subnet 2, IPv4
Rule Nameonpremise
Rule Rule TypeForward
Domain Namefirewall.lan
VPC Rulevpc-aws-vpc
Target IP #110.0.1.2:53
Target IP #210.0.4.2:53

Inbound Endpoint

Inbound Endpoint config-a

Inbound Endpoint config-b

Endpoint Nameie-aws
VPCvpc-aws-vpc
Security GroupDefault
Endpoint TypeIPv4
IP Address #1AZ us-east-1, subnet 1, IPv4
IP Address #2AZ us-east-2, subnet 2, IPv4

Site to Site

Site to Site

  • Use IPsec tunnels to connect AWS to another datacenter
  • Have a failover connection for High availability

Site to Site config-a

Site to Site config-b

Site to Site config-c

Site to Site config-d

||| |:-:|:-:|:-:| |AWS|s2s-aws-pfsense| |Target gateway type|Transit Gateway| |Transit Gateway|TGW| |Customer Gateway|CGW| |Routing Options|Dynamic| |Tunnel inside IP|IPv4| |Inside IPv4 CIDR for tunnel 1|169.254.11.0/30| |Pre-shared key for tunnel 1|strong password| |Inside IPv4 CIDR for tunnel 2|169.254.12.0/30| |Pre-shared key for tunnel 2|strong password|

Status

Status

  • When BGP session is established, the status will go from down to up

SSM

AWS-SSM

  • Using AWS System Manager will allow remote access without opening any ssh ports
  • Use to keep your network private
  • Use to debug any connectivity issues

IAM Role Policy

{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ssm:DescribeAssociation",
"ssm:GetDeployablePatchSnapshotForInstance",
"ssm:GetDocument",
"ssm:DescribeDocument",
"ssm:GetManifest",
"ssm:GetParameter",
"ssm:GetParameters",
"ssm:ListAssociations",
"ssm:ListInstanceAssociations",
"ssm:PutInventory",
"ssm:PutComplianceItems",
"ssm:PutConfigurePackageResult",
"ssm:UpdateAssociationStatus",
"ssm:UpdateInstanceAssociationStatus",
"ssm:UpdateInstanceInformation"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"ssmmessages:CreateControlChannel",
"ssmmessages:CreateDataChannel",
"ssmmessages:OpenControlChannel",
"ssmmessages:OpenDataChannel"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"ec2messages:AcknowledgeMessage",
"ec2messages:DeleteMessage",
"ec2messages:FailMessage",
"ec2messages:GetEndpoint",
"ec2messages:GetMessages",
"ec2messages:SendReply"
],
"Resource": "*",
"Effect": "Allow"
}
]
}

Endpoint

SSM Endpoint

ssm Endpoint config-a

ssm Endpoint config-b

ssm Endpoint config-c

||| |:-:|:-:|:-:| |Name|ssm-endpoint| |Service Category|AWS Service| |Service|SSM| |VPC|vpc-aws-vpc| |Subnets|us-east-1, us-east-2| |Security Group|Default| |Policy|Full Access|

SSMMessage Endpoint

Image description a

||| |:-:|:-:|:-:| |Name|ssmmessage-endpoint| |Service Category|AWS Service| |Service|SSMmessages| |VPC|vpc-aws-vpc| |Subnets|us-east-1, us-east-2| |Security Group|Default| |Policy|Full Access|

EC2Message Endpoint

Image description b

||| |:-:|:-:|:-:| |Name|ec2message-endpoint| |Service Category|AWS Service| |Service|ec2messages| |VPC|vpc-aws-vpc| |Subnets|us-east-1, us-east-2| |Security Group|Default| |Policy|Full Access|

Azure

Azure

VNET

VNET

  • Create a Virtual Network on Azure

Resource Group

RG Review

  • Resource Group provides a single detailed view of all resources in a groups stack
Resource grouprg-aws-azure
RegionEast US

Virtual Network

Vnet Review

  • This Iaas will build a virtual network similar to a VPC
  • Create 1 network /24 CIDR to create 4 subnets with /26 CIDR
Resource grouprg-aws-azure
Namevnet-aws-azure
RegionEast US
BastionDisabled
FirewallDisabled
DDoSDisabled
Adress Space172.16.12.0/24
Subnet172.16.12.0/26

VWAN

VWAN

  • TODO: Azure VWAN
  • Have a AWS site-to-site connection config to populate data

Local Network Gateway

LNG Review

  • IP of the customer/data center Gateway
Resource grouprg-aws-azure
RegionEast US
EndpointIP Address
IP Address1.1.1.1
Address Space(s)None
ASN64512
BGP169.254.21.1
Reserved APIPA

||| |:-:|:-:|:-:| |AWS|169.254.0.0/16| |Azure|169.254.21.0/24 - 169.254.22.0/24|

Virtual Network Gateway

VNG Review

Resource grouprg-aws-azure
RegionEast US
SKUVPNGw2AZ
Generation2
VNETvnet-aws-azure
Subnet172.16.12.64/27
Gateway TypeVPN
VPN TypeRoute Based
Active-activeDisabled
BGBEnabled
ASN65000
Custom APIPA169.254.21.2, 169.254.22.2
Public IP adressvng-aws-azure-pip

Private Resolver

Private Resolver

Connection

Connection

  • Use to create an IPsec connection using BGP
  • Create a second connection for failover

Conn Review

Resource grouprg-aws-azure
RegionEast US
Connection typeSite-to-site(IPsec)
Connection nameconn-1-aws-azure
Virtual Network Gatewayvng-aws-azure
Local Network Gatewaylng-aws-azure
IKE ProtocolIKEv2
IpSec / IKE policyDefault
Use Policy based traffic selectorDisable
DPD timeout45
Connection ModeDefault
BGP169.254.21.2

BGP

VNG Sidebar

Connection Status

  • Verify Connection is enabled
  • Create second connection for failover

BGB Status

  • Verify Route propagation from BGP

Azure VM

Ping

  • Azure -> AWS

GCP

GCP

VPC

VPC

  • Create a Virtual Private Cloud on Google

VPC config-a

VPC config-b

VPC config-c

Namevpc-gcp-aws
DescriptionVPC
IPv6Disabled
SubnetCustom
Subnet NamePrivate
Subnet Regionus-east-1
IP stackIPv4
IP range172.16.13.0/24
Private Google Accessoff
Flow Logsoff
IPv4 Firewall RuleIngress Apply to all 0.0.0.0/0 ICMP Allow
Dynamic RoutingRegional

Network Connectivity Center

Network Connectivity

Cloud Router

Cloud Router

Namecr-gcp
Descriptionroute
Networkvpc-gcp-aws
Regionus-east-1
ASN65000
Interval20
RoutesAdvertise all subnets to CR

VPN Gateway

VPN Gateway

Namevpn-gcp-aws
Networkvpc-gcp-aws
Regionus-east-1
IP stackIPv4

Cloud DNS

Cloud DNS

Peer VPN

Peer VPN

  • Set up the infrastructure for GCP VPN

Peer VPN config-a

Peer VPN config-b

Peer VPN config-c

  • Repeats these steps on interface 1 (failover)
Namevpng-gcp-aws
Interfacestwo interfaces
Interface 03.3.3.3
Interface 13.3.3.2
Peer VPN GatewayOn-Prem or Non Google
Peer VPNG Namevpng-gcp-aws
High AvailabilityCreate a pair of VPN tunnles
Cloud Routercr-gcp
Associated Peer VPNG interface0: 1.1.1.1
Nameconn1-gcp-aws
pre-shared keystrong password
Peer ASN64512

BGP

BGP

Nameconn1
Peer ASN64512
BGB IPv4 addressManually
Cloud Router BGP169.254.250.138
BGP Peer Address169.254.250.137

BGP Status

  • Verify Dynamic Route update

GCP vm

Image description

  • GCP -> AWS

PFSense

Pfsense

VLAN

Check out this write-up on how to configure VLANs with pfsense

ISP

TODO: Check out this write-up on how to configure a VPN Server with pfsense

PiHole

TODO: Check out this write-up on how to configure a DNS server with PiHole

IPSec

Phase 1

Edit Tunnel 1

  • Start by creating a primary tunnel and repeat the below steps for the failover connection tunnel 2

Tunnel1 Config-a

Tunnel1 Config-b

Descriptionconn1-aws-pfsense
Key Exchange versionIKEv2
Remote Gateway1.1.1.1
Pre-Shared Keystrong password key token
AlgorithmAES
Key Length128 bits
HashSHA256
DH Group14 (2048 bit)
Max failures3

Phase 2

Edit Tunnel 2

  • Start by creating a primary tunnel and repeat the below steps for the failover connection tunnel 2

Tunnel1 Config-a

Tunnel1 Config-b

Tunnel1 Config-c

Descriptionconn1-aws-pfsense
ModeRouted (VTI)
Local Networkaddress: 169.254.11.12
Remote Networkaddress: 169.254.11.11
Encryption AlgorithmAES256-CGM 128bits
Ping Host172.16.11.11
Keep AliveEnabled

Status

Image description

  • Both primary and failover tunnels connected with IPSec

BGP

FRR Global Settings

Global Settings

Enabledtrue
Master Passwordstrong password
FRR Route Maps

Route Maps

Route Maps config

NameAllow-all
ActionPermit
Sequence100
FRR BGB

FRR BGB

BGB-config-a

BGB-config-b

Enabledtrue
Local AS65000
Router ID10.0.1.1
Networks to distrbute10.0.1.0/28, 10.0.2.0/29, 10.0.4.0/28
FRR Neighbors

FRR Neighbors

  • Start with the primary tunnel and repeat the steps for the failover tunnel

FRR Neighbors config-a

FRR Neighbors config-b

FRR Neighbors config-c

Name/Address169.254.11.12
Descriptionconn1-aws-pfsense
Remote AS64512
Inbound Route Map FiltersAllow-all
Outbound Route Map FiltersAllow-all
FRR Status

Status Routes

  • Verify Dynamic Routes have been updated

Status Summary

  • View the BGP Summary

Mac

Mac

  • Mac -> AWS