How to create a VPN between Azure and AWS using only managed solutions
Published Jun 17 2021 12:48 PM 109K Views
Microsoft

What if you can establish a connection between Azure and AWS using only managed solutions instead to have to use virtual machines? This is exactly what we'll be covering on this article connecting AWS Virtual Private Gateway with the Azure VPN Gateway directly without worry to manage IaaS resources like virtual machines.

 

Below the draw of our lab:

draw.png

 

Regarding the high availability, please note that on AWS, by default a VPN connection always will have 2 Public IPs, one per tunnel. On Azure it doesn't happens by default and in this case you will be using Active/Passive from Azure side.

 

This means that we will be setting only one "node" from Azure VPN Gateway to establish two VPN connections with AWS. In case of a failure, the second node from Azure VPN Gateway will connect to AWS in a Active/Passive mode.

 

Configuring Azure

 

1. Crate a resource group on Azure to deploy the resources on that

 

newrg.png

 

create.png

 

Choose the subscription, the name and the region to be deployed:

 

creating.png

 

2. Create a Virtual Network and a subnet

 

createvnet.png

 

createvnetbutton.png

 

Define the subscription, resource group, name and region to be deployed:

 

vnetdefinitions.png

 

Set the address space for the virtual network and for the subnet. Here I'm defining the virtual network address space to 172.10.0.0/16, changing the "default" subnet name to "subnet-01" and defining the subnet address range to 172.10.1.0/24:

 

vnetaddr.png

 

vnetvalidation.png

 

3. Create the VPN Gateway

 

The Azure VPN Gateway is a resource composed of 2 or more VM's that are deployed to a specific subnet called Gateway Subnet where the recommendation is to use a /27. He contain routing tables and run specific gateway services. Note that you can't access those VM's.

To create, go to your Resource Group, then click to + Add

 

addvpngw.png

 

newvpngw.png

 

createvpngw.png

 

Then fill the fields like below:

 

vpngwsummary.png

 

After click to Review + create, in a few minutes the Virtual Network Gateway will be ready:

 

vpnready.png

 

Configuring AWS

 

4. Create the Virtual Private Cloud (VPC)

 

createvpc.png

 

5. Create a subnet inside the VPC (Virtual Network)

 

createsubnetvpc.png

 

6. Create a customer gateway pointing to the public ip address of Azure VPN Gateway

 

The Customer Gateway is an AWS resource with information to AWS about the customer gateway device, which in this case is the Azure VPN Gateway.

 

createcustomergw.png

 

7. Create the Virtual Private Gateway then attach to the VPC

 

createvpg.png

 

attachvpgtovpc.png

 

attachvpgtovpc2.png

 

8. Create a site-to-site VPN Connection

 

createvpnconnection.png

 

Set the routing as static pointing to the azure subnet-01 prefix (172.10.1.0/24)

 

setstaticroute.png

 

After fill the options, click to create.

 

9. Download the configuration file

 

Please note that you need to change the Vendor, Platform and Software to Generic since Azure isn't a valid option:

 

downloadconfig.png

 

In this configuration file you will note that there are the Shared Keys and the Public Ip Address for each of one of the two IPSec tunnels created by AWS:

 

ipsec1.png

 

ipsec1config.png

 

ipsec2.png

 

ipsec2config.png

 

After the creation, you should have something like this:

 

awsvpnconfig.png

 

Adding the AWS information on Azure Configuration

 

10. Now let’s create the Local Network Gateway

 

The Local Network Gateway is an Azure resource with information to Azure about the customer gateway device, in this case the AWS Virtual Private Gateway

 

newlng.png

 

createnewlng.png

 

Now you need to specify the public ip address from the AWS Virtual Private Gateway and the VPC CIDR prefix.

Please note that the public address from the AWS Virtual Private Gateway is described at the configuration file you have downloaded.

As mentioned earlier, AWS creates two IPSec tunnels to high availability purposes. I'll use the public ip address from the IPSec Tunnel #1 for now.

 

lngovwerview.png

 

11. Then let's create the connection on the Virtual Network Gateway

 

createconnection.png

 

createconnection2.png

 

You should fill the fields according below. Please note that the Shared key was obtained at the configuration file downloaded earlier and In this case, I'm using the Shared Key for the Ipsec tunnel #1 created by AWS and described at the configuration file.

 

createconnection3.png

 

After a few minutes, you can see the connection established:

 

connectionstablished.png

 

In the same way, we can check on AWS that the 1st tunnel is up:

 

awsconnectionstablished.png

 

Now let's edit the route table associated with our VPC

 

editawsroute.png

 

And add the route to Azure subnet through the Virtual Private Gateway:

 

saveawsroute.png

 

12. Adding high availability

 

Now we can create a 2nd connection to ensure high availability. To do this let's create another Local Network Gateway which we will point to the public ip address of the IPSec tunnel #2 on the AWS

 

createlngstandby.png

 

Then we can create the 2nd connection on the Virtual Network Gateway:

 

createconnectionstandby.png

 

And in a few moments we'll have:

 

azuretunnels.png

 

awstunnels.png

 

With this, our VPN connection is established on both sides and the work is done.

 

13. Let's test!

 

First, let's add an Internet Gateway to our VPC at AWS. The Internet Gateway is a logical connection between an Amazon VPN and the Internet. This resource will allow us to connect through the test VM from their public ip through internet. This is not required for the VPN connection, is just for our test:

 

createigw.png

 

After create, let's attach to the VPC:

 

attachigw.png

 

attachigw2.png

 

Now we can create a route to allow connections to 0.0.0.0/0 (Internet) through the Internet Gateway:

 

allowinternetigw.png

 

On Azure the route was automatically created. You can check selecting the Azure VM > Networking > Network Interface > Effective routes. Note that we have 2 (1 per connection):

 

azureeffectiveroutes.png

 

Now I've created a Linux VM on Azure and our environment looks like this:

 

azoverview.png

 

And I did the same VM creation on AWS that looks like this:

 

awsoverview.png

 

Then we can test the connectivity betweeen Azure and AWS through our VPN connection:

 

azureping.png

 

awsping.png

 

Update: If you want to deploy a solution more resilient and using BGP, follow this documentation: https://docs.microsoft.com/en-us/azure/vpn-gateway/vpn-gateway-howto-aws-bgp

18 Comments
Iron Contributor

Thanks @rmmartins 

Copper Contributor

@rmmartins 
Thank you very much for the steps.
I need some high level guidance for our use-case, if you don't mind please. 
Ours is a early stage startup company. We are trying to setup secure employees login/connections to our AWS environment. We have all our 10 employees using office365. We do have Azure subscription too. 

How could I setup this use-case:-

Create Azure VNet Gateway and Azure VPN (I think we know steps for this).
Create a Virtual Desktop (either Ubuntu or Windows,  in AWS or within Azure) for Multi-User session mode. 
All our employees should login to Azure VPN client on their own personal laptops using Azure AD(O365) login; after that employees should login to the Virtual Desktop using SSO via Azure AD.  After logging in to Virtual Desktop only our engineers should be able to connect to our AWS resources like AWS EKS or AWS RDS or anything which is in our AWS private subnet using  AWS SSO via Azure AD. 

Please provide some high level steps or point me to some resources which could help. Please & Thank you. 

Copper Contributor

@Chandu_P , use Azure AD Aplication Proxy to publish Private Web Applications, without using VPN or connections between Azure and AWS, you only need to deploy a proxy Machine in you AWS VPC with Internet Connection.

For AWS administrative tasks, in management console, use AWS SSO + Azure AD

Copper Contributor

During step 11 while creating the connection in Azure, I'm getting the "Unknown" status on the connection.  I'm getting something similar in AWS.  Configuration seems like it is correct, although clearly I'm doing something wrong.  Does anyone know what causes the "Unknown" status?  I'm not seeing any clear documentation on it anywhere.

Copper Contributor

hi microworker

 

check public ip addresses in both ends of the tunnel and secret key again.

 

And wait. sometimes i wait for like 5 to 10 minutes for tunnels to go up, sometimes it is almost instant

Copper Contributor

@stefanalex2360 

 

I did do that, but they were definitely correct.  I did upgrade the gateway from vpngw1 to vpngw2 and tunnel 1 immediately came up.  But now I can't get the second tunnel up. 

Copper Contributor

Hi,

 

Thank you for the nice step-by-step article! I just tried the steps mentioned in the article. So, from the Azure side when we are creating a virtual network gateway, we are disabling BGP. But, from AWS side when we are creating a customer gateway with the public IP of the Azure Virtual network gateway, we cannot disable BGP. If BPP related text field is left blank, then it is asking me to enter something, as shown in the screenshot below. So, It cannot be left blank. Not sure how BGP did not appear in the screenshot that you provided for configuring CGW in AWS.

 

Now, if I enable BGP ( by providing a BGP ASN as 65001) then will it be able to communicate with Azure once the Virtual private gateway is set up and attached to the corresponding VPC? If not, then how to make the connectivity work?

 

Rajarshi1590_0-1652149797702.png

 

 

Copper Contributor

Hello,

 

Bottom line up front: Need assistance moving DB from AWS to Azure

 

Thanks for the article above. I am working on a project in which we are trying to transfer several existing PostgreSQL DB from AWS to Azure. We have followed all directions that we can find online to use the Azure DMS but we cannot establish a successful connection between the DMS and AWS. The problem occurs on the 'Select Source' page of the Azure DMS. During the validation step I get an error stating 'Failed to connect'. I have been working on this for a few weeks trying different solutions. I get a different error if I purposely enter incorrect source info, so I believe that Azure is talking to AWS, but not creating the required connection.

 

I followed all of the steps in the above article and can see that both AWS tunnels are up and the connection in Azure shows connected. However, I still can't get a connection to allow transfer of the DBs from AWS to Azure. Can anyone help? 

Copper Contributor

In your examples you use 172.10.0.0/16, but those are public IP addresses assigned to AT&T. Configuring them on a private subnet is likely to cause connectivity issues with parts of the internet. Recently some members of my team configured a VPN using those values copied from your tutorial and now I'm asking them to redo their work to use private address space instead.

May I suggest switching your tutorial to 172.16.0.0/16 which is an appropriate private space instead.

Copper Contributor

It's very precise and clear content. Loved it.

I have successfully completed my use case for VPN connectivity with high availability between Azure and AWS cloud.

Thanks Once again for your great content.

 

 

Thanks,

Anoop Singh

Copper Contributor

Muchas gracias! funcionó a la perfección, pero si tuve que cambiar a sku VpnGW2

Copper Contributor

I did all the setup as mentioned in above step my tunnel is also up and vpn is also connected.

but when im doing the ping from aws to azure and azure to aws its not working 
showing

 --- 10.34.0.4 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2052ms 

Copper Contributor

Hi @sonali335 ,
Could you pls try the below

In AWS side of the config, in the Site-to-Site VPN connections, under "Static routes" add the IP prefix of the Azure VM i.e. 172.10.1.0/24
Also ensure the route propagation is enabled in the route table config.

Hope this helps.

Copper Contributor

Saw this after many hours of pulling my hair out...."Also ensure the route propagation is enabled in the route table config."

After enabling, my issues were resolved. 

FYI: Great article !

Copper Contributor

I am able to ssh from AWS to Azure, but not from Azure to AWS. On both end, the tunnel connectivity shows as connected. 

Also if we plan to add another Azure region, is there a way to use existing tunnel or do I need to setup another tunnel between Azure East to AWS.

Copper Contributor

@rmmartins @mshah1525 Were you able to resolve it? I am having same issue.

I can ssh from AWS to Azure but not the other way.

I can ping both ways.

Copper Contributor

If your GatewaySubnet have a route table, ensure Propagate gateway routes is set to true for the gateway.

Copper Contributor

Yes, we were configuring the route table and hence the "Propagate gateway routes" which the VPN was configuring were invalidated. Once we deleted our routing configuration, it started working fine.

We see the VPN routing configuration, once we create a VM and look at the Network config. Is there any other place we can see all the routing configuration?

Co-Authors
Version history
Last update:
‎Aug 22 2022 04:50 PM
Updated by: