Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET
Cloud Computing

Connect Two Azure Resource Manager Virtual Networks Using VPN


In this post I will show you how to connect two Azure virtual networks that are in the same subscription using a VNet-to-VNet VPN tunnel.

The Solution

This solution allows two VNets in two different regions to be connected at the network layer. A gateway is created in each VNet, and the gateways are configured to connect to each other using a VPN tunnel. This provides a secure tunnel through which virtual machines on each VNet can communicate with each other. There are no security filters by default, but you can add or modify Network Security Groups to allow/block traffic.

An Azure VNet-to-VNet VPN [Image Credit: Microsoft]
An Azure VNet-to-VNet VPN [Image Credit: Microsoft]


The solution shown in this post allows you to connect VNets that are in the same Azure subscription. You will follow a slightly different process if the VNets will reside in different subscriptions.

Sponsored Content

Say Goodbye to Traditional PC Lifecycle Management

Traditional IT tools, including Microsoft SCCM, Ghost Solution Suite, and KACE, often require considerable custom configurations by T3 technicians (an expensive and often elusive IT resource) to enable management of a hybrid onsite + remote workforce. In many cases, even with the best resources, organizations are finding that these on-premise tools simply cannot support remote endpoints consistently and reliably due to infrastructure limitations.



There are some prerequisites for configuring a VNet-to-VNet VPN connection:

  • IP Addressing: The two VNets must not use overlapping network addresses. For example, you cannot connect a VNet to another VNet.; this should make sense because how would those networks route? Always plan network addresses in advance, allowing for the fact that, one day, a VNet might need connectivity to either another VNet or a customer LAN, even if that day is far in the future.
  • Gateway: Each VNet will require a gateway. It takes 45-60 minutes for Azure to deploy a gateway appliance. I typically schedule my time around this; for example, going home, getting lunch, or finding something else to do.
  • Route-Base Gateway: VNet-to-VNet VPN requires that you use a route-based (aka dynamic) gateway. If you are using site-to-site VPN to connect on-premises networks, then verify that your firewall can support route-based VPN — not that a VNet can only have 1 gateway. Don’t make assumptions — some big names and well-known devices (Cisco ASA, for example) are limited to outdated policy-based VPN. You might find that you need to replace your on-premises firewalls.
  • Scalability: Traffic between the VNets will be limited by the maximum supported VPN speed of the gateway. Note you can create a mesh of VNet (3+) connections up to the limits of the gateway. The maximum bandwidth of the gateway will be shared by those connections.
  • Pricing: There is a charge for running VPN gateways. There is no charge for cross-VPN traffic if both VNets are in the same region. The outbound data transfer charge applies if the VNets are in different regions.

I used a pair of VNets, one in East US (Virginia) and one in North Europe (Dublin), to demonstrate the inter-VNet VPN connection in this post.

Create Public IP Addresses

Each VNet will have a gateway. Each gateway will require a public IP (PIP) address to allow a cross-Internet connection. I like to create these PIP addresses in advance and ensure that they are configured with a static (or reserved) address.

Open the Azure Portal and create a public IP Address for the first gateway:

  1. Name the PIP address.
  2. Leave the address as dynamic.
  3. Give the new PIP address a unique DNS name.
  4. Add the PIP to the resource group that you will create the gateway in. I use the same resource group that the VNet is in.
  5. Make sure that the region will match the VNet’s region.

Create a dynamic public IP address in Azure [Image Credit: Aidan Finn]
Repeat the above steps to create a PIP for the second VNet, and wait for the confirmation that both PIP addresses have been created before you continue.

Create Gateways

The gateway initiates and terminates the VPN tunnel, connecting the local network to the remote network using a secured tunnel via the Internet.

Create a virtual network gateway for the first VNET:

  1. Enter the name of the new gateway.
  2. Ensure that the Gateway Type is set to VPN and the VPN Type is set to Route-Based.
  3. Set the SKU according to the required VPN speed and number of VPN connections.
  4. Identify the region of the VNet that this gateway will be directly connected to — that is the local network, not the remote one that the gateway will connect to via VPN. Set the Location to the match the VNet’s region.
  5. Select the VNet.
  6. Set the subnet; I like to use the last VNet and set the subnet mask to be as small as is supported (/29 or 8 addresses).
  7. Select the PIP address that you previously created for this gateway.
  8. Click Create.

Creating a new VPN gateway in Azure [Image Credit: Aidan Finn]
Creating a new VPN gateway in Azure [Image Credit: Aidan Finn]
Repeat these steps to create a gateway in the second VNet. And then wait for 45-60 minutes.

Configure VPN Connection

Browse to the first virtual network gateway, and click Connections. Click Add to create a connection. Enter the following details:

  1. Name: Give the connection a meaningful name.
  2. Connection type: Set this to VNet-to-VNet.
  3. First virtual network gateway: This should be the current gateway.
  4. Second virtual network gateway: Select the gateway of the remote VNet.
  5. Shared key: Enter some long random string that both gateways will require — save this key because you will need it again.

Verify that the resource group is correct for the first gateway and click OK.

Creating an Azure VNet-to-VNet VPN connection [Image Credit: Aidan Finn]
Creating an Azure VNet-to-VNet VPN connection [Image Credit: Aidan Finn]
Wait for the connection to be created, and then repeat the process on the second gateway, using the exact same pre-shared key. You need to have successfully created both connections before the VPN tunnel will be initiated by the gateways.

A VNet-to-VNet tunnel is started in Azure after both connections are created [Image Credit: Aidan Finn]
A VNet-to-VNet tunnel is started in Azure after both connections are created [Image Credit: Aidan Finn]
After a few minutes, the tunnel will be created, and you can verify communications using virtual machines that are connected to both VNets.

Related Topics:


Don't have a login but want to join the conversation? Sign up for a Petri Account

Comments (0)

Leave a Reply

Aidan Finn, Microsoft Most Valuable Professional (MVP), has been working in IT since 1996. He has worked as a consultant and administrator for the likes of Innofactor Norway, Amdahl DMR, Fujitsu, Barclays and Hypo Real Estate Bank International where he dealt with large and complex IT infrastructures and MicroWarehouse Ltd. where he worked with Microsoft partners in the small/medium business space.
Live Webinar: Active Directory Security: What Needs Immediate Priority!Live on Tuesday, October 12th at 1 PM ET

Attacks on Active Directory are at an all-time high. Companies that are not taking heed are being punished, both monetarily and with loss of production.

In this webinar, you will learn:

  • How to prioritize vulnerability management
  • What attackers are leveraging to breach organizations
  • Where Active Directory security needs immediate attention
  • Overall strategy to secure your environment and keep it secured

Sponsored by: