How I Built an AWS Dynamic, BGP Based, Highly-Available Site-to-Site VPN

Search for a command to run...

No comments yet. Be the first to comment.
Get good grades, go to college, get a good job, and work for retirement: This is a message that was given to me and many others in our youth. This is a message that was supplied by teachers, parents, and our role models. Does this path work, and w...

Overview CloudFomation makes it easy to deploy infrastructure as code. It allows us to create a template containing logical resources and deploy it as a "stack" in 1 step. This is faster, repeatable and more consistent than deploying resources manual...

I recently stumbled across this interesting project on aws.amazon.com. The project/tutorial walks you through setting up a well-architected modern web application called Mythical Mysfits that enables visitors to adopt a fantasy creature (mysfit) ...

A few months ago, one of my LinkedIn connections introduced me to the cloud resume challenge. The challenge instructs participants to build a "serverless" resume website using HTML/CSS and AWS cloud infrastructure, deploy the infrastructure using IaC...

As the title suggests, I was able to setup and implement a Site to Site VPN from an AWS Virtual Private Cloud (VPC) to a simulated on-premise environment utilizing the Border Gateway protocol (BGP) to configure the routes.
This article details how I was able to complete this. From a high level, this is the process that was followed:
The goal in this demo is to connect an AWS VPC to a simulated on-premise environment using a secure and highly available VPN connection.

I started by deploying two cloud formation templates supplied by @Adrian Cantrill to setup the base infrastructure.
The first cloud formation template represents the AWS infrastructure side and includes the following:
The second cloud formation template simulates the on-premise environment using AWS resources:
Then, I setup two customer gateways to simulate two on-premise routers. Having two customer gateways allows for the creation of a highly available environment. In the real world these gateways would likely be in two separate locations to ensure availability.

These routers were configured to use Dynamic routing, which allows the use of the dynamic BGP routing protocol. I assigned a private Autonomous System Number, and assigned public IPs to these routers.

At this stage there was no connectivity between the On-prem and AWS network. I was able to confirm this by running a ping test:

With the environment in place, I moved onto creating the transit gateway VPN attachments. These attachments essentially create a secure VPN connection from the transit gateway to the customer gateway.
In our on-prem environment there are two customer gateways. I navigated to the AWS VPC console and setup two transit gateway attachments, one for each gateway.
For each attachment, I selected the transit gateway which was created in the "AWS" cloud formation template. I also chose dynamic routing (for BGP) and allowed "Enable Acceleration" to speed up our routing traffic.

At this stage, I was able to set up multiple IPSec tunnels. The IPSec tunnels span from the customer gateway to the VPN endpoints. These tunnels encrypt and secure the data as it traverses the public internet.

To setup the IPSec tunnels, I first gathered a bit of information. I pulled the router IP's and I also downloaded the VPN config files from the VPC console. These files contain several bits of information.
They contain some of the following items:

In this demo we used EC2 instances on the simulated on-premise side to act as routers, and utilized strongSwan to act as our IPSsec VPN.
To configure the IPsec tunnel, I had to edit a few files that strongSwan uses. I edited the following files:
With strongSwan configured one is able to see that the IPSec shows as "up" in the AWS console.

The tunnel, however, shows as down. This is because BGP is not configured yet. Due to the BGP/routing not being configured, traffic from the AWS servers cannot successfully reach the on-prem servers at this stage:

To allow traffic from the AWS servers to reach on-prem and vise versa, I needed to configure the customer gateways to use BGP.
In this specific demo I installed FRR on the customer gateways to allow BGP capabilities.

For each of the tunnels I then added AWS as the neighboring route on the customer gateway.

The on-prem and AWS servers are now able to successfully communicate using our Dynamic, BGP Based, Highly-Available Site-to-Site VPN!

This architecture was designed to be highly available. There are multiple VPN endpoints, Customer Gateways, and EC2 instances. I also configured IPSec tunnels to encrypt our data in transit and ensure security.
Thank you to @Adrian Cantrill for creating this demo!
I appreciate everyone who made it this far down!