Lab 08 Site-To-site VPN
Lab 08 Site-To-site VPN
Lab 08 Site-To-site VPN
Author:
Binal Shah
Principal Cloud Solution Architect, Microsoft
Lab Overview
In this lab, we will create a site to site IPSec VPN connection between two virtual networks
within Azure. The vnet configuration is as shown in the lab diagram below.
Lab Diagram
Create a virtual network using CLI
Open cloud shell window. Cloud Shell icon can be found on the top right of the portal.
Define the following variables and run the command to create a virtual network
onprem.
ResourceGroup=rg-lab
VnetName=onprem
VnetPrefix=10.128.0.0/16
SubnetName=onprem-subnet1
SubnetPrefix=10.128.1.0/24
Location=westus2
If you don't already have virtual network vnet-hub created, follow steps from lab on
Azure CLI to add this virtual network.
Create GatewaySubnet
1. In the portal, on the left side, click + Create a resource and type 'Virtual Network
Gateway' in search. Locate Virtual network gateway in the search return and click the
entry. On the Virtual network gateway page, click Create. This opens the Create virtual
network gateway page.
2. On the Create virtual network gateway page, fill in the values for your virtual network
gateway.
o Subscription: Select the subscription you want to use from the dropdown.
o Resource Group: rg-lab
o Name: vnet-hub-vpn-gw
o Region: West US 2
o Gateway type: Select VPN.
o VPN type: Route-based
o SKU: VpnGw1
o Virtual network: vnet-hub
o Gateway subnet address range: 10.0.254.0/27
o Public IP address: Leave Create new selected.
o Public IP address name: vnet-hub-vpngw-ip1
o Active-Active mode: Disabled
o Configure BGP ASN: Enabled
o Autonomous System number (ASN): 65001
o Click Review + Create to run validation.
o Once validation passes, click Create to deploy the VPN gateway.
A gateway can take up to 45 minutes to fully create and deploy. You can see
the deployment status on the Overview page for your gateway.
Create a VPN gateway in virtual network onprem with the following values:
o Subscription: Select the subscription you want to use from the dropdown.
o Resource Group: rg-lab
o Name: onprem-vpn-gw
o Region: West US 2
o Gateway type: Select VPN.
o VPN type: Route-based
o SKU: VpnGw1
o Virtual network: onprem
o Gateway subnet address range: 10.128.254.0/27
o Public IP address: Leave Create new selected.
o Public IP address name: onprem-vpngw-ip1
o Active-Active mode: Disabled
o Configure BGP ASN: Enabled
o Autonomous system number (ASN): 65002
o Click Review + Create to run validation.
o Once validation passes, click Create to deploy the VPN gateway.
Create local network gateway to configure details of the virtual network vnet-hub.
Go to the Search bar at the top of the Azure portal. Type in Virtual Network Gateway.
Select Virtual Network Gateway from the search results.
2. On the Add connection page, configure the values for your connection.
o Name: vpn-tunnel-onprem-to-vnet-hub
o Connection type: Select Site-to-site(IPSec).
o Virtual network gateway: onprem-vpn-gw
o Local network gateway: Click Choose a local network gateway.
Select vpn-hub-local-network-gateway.
o Shared Key: key1234!
o IKE protocol: IKEv2
o The remaining values for Subscription, Resource Group, and Location are fixed.
o Click OK to create your connection.
o You can view the connection in the Connections page of the virtual network gateway. The
Status will go from Unknown to Connecting, and then to Succeeded.
In the Azure portal, you can view the connection status of a Resource Manager VPN
Gateway by navigating to the connection. The following steps show one way to navigate
to your connection and verify.
1. In the Azure portal, click All resources and navigate to your virtual network gateway.
2. On the blade for your virtual network gateway, click Connections. You can see the status
of each connection.
3. Click the name of the connection that you want to verify to open Essentials. In Essentials,
you can view more information about your connection. The Status is 'Succeeded' and
'Connected' when you have made a successful connection.
Verify the VPN connection
To verify the connection, create a virtual machine in the vnet onprem and verify
private connectivity to a virtual machine vnet-hub-vm1 in vnet vnet-hub.
ResourceGroup=rg-lab
VmName=onprem-vm1
VnetName=onprem
SubnetName=onprem-subnet1
AdminUser=azureuser
AdminPassword=Azure123456!
1. From the portal, go to the Virtual network page and click on vnet-hub.
2. Go to Peerings under Settings and click on the peering link configured to
vnet1
3. peer-vnet-hub-to-vnet1.
4. Check the box for Allow gateway transit.
5. Next, go back to the virtual network page and click on vnet1. This should
take you to the Overview page for virtual network vnet1.
6. Click on Peerings under settings and then click on the peering link peer-
vnet1-to-vnet-hub.
7. Check the box for Use remote gateways.
Conclusion
We successfully established communication between (simulated) on-premises site
and virtual network in Azure using site-to-site VPN. We also verified gateway
transit functionality with peered networks. We saw how to leverage hub and spoke
topology and use gateway transit to enable spoke networks to reach on premises
network.