This lab will focus on creating a secure site-to-site VPN that can be used as a cost-saving option for branch offices, hybrid cloud connectivity, or centralizing resources securely without exposing them to the public internet. By the end of this lab, you will understand how to connect your local site to your Azure cloud environment using the topology below.

Prerequisites:

If you do not have a static IP, you might want to consider using a service like noip (DDNS) so you can use a fully qualified domain name rather than your WAN IP, since ISPs utilize dynamic IPs. This is not a requirement, but it might be helpful if you plan to utilize this outside this lab.

Azure Configuration

Now onto the fun parts. Create a Resource group in your desired region (make sure this stays the same throughout the lab) called RG-S2SVPN.

Next, we will create a Virtual Network Gateway with the following settings:

Deploying a Virtual Network Gateway can take some time, so we'll move along and check back with deployment towards the end.

Next, we are going to make a VM on our Azure side. We will use this later to confirm that our tunnel is working correctly and that our on-site and cloud resources can securely communicate over the internet.

Navigate to your Resource group we created for this lab, then hit +Create, search for Virtual Machine, and hit Create.

Virtual Machine Settings:

Next, we create a Local Network Gateway, which acts as a pointer to your on-premises gateway/firewall. Navigate to your lab resource group, then hit Create, then search for Local network gateway and select it.

Local Network Gateway Settings:

Connection Creation

We’re almost there; all we need to do is connect our cloud infrastructure to our on-site infrastructure. We start by, you guessed it Creating a connection. Select Create from your resource group and search for a connection, then select.

Create Connection Settings:

Once the connection is created, access the resource, and we will adjust some settings to harden it a bit. Goto settings, then configuration. Change the IPsec / IKE policy to custom, then match these configurations:

Make sure these configurations match your on-prem device in the next step.

On-Site Configuration

This will differ if using a device other than a UniFi gateway device, but I will do my best to explain the concepts along the way, which should translate across devices.

Create a new network; this will be the private network used to communicate with your cloud environment. In my example, I used the 192.168.200.0/24 address space. When creating this network, ensure it does not overlap with the address space configured in the cloud. If you followed along, that would be 10.1.0.0/16 space, so we’re all set here.

The key details for configuration are the following:

UniFi site-to-site VPN settings UniFi site-to-site remote device settings

Once you are done, verify the connection by going to Azure and checking the IPsec-S2S connection status (you can also check this under settings/connections on the VNG-S2S).

If you really want to understand how cool this is, navigate to the VM-S2S deployed earlier, open the Connect Tab, and select Connect. Open your favorite terminal and copy/paste the ssh code provided by Azure into your local shell.

When prompted to continue connecting, type yes, then paste the password created in the previous VM step (thisisaverystrongpassword123!). You are now in your cloud VM. Now, ping a device on the local network you created the tunnel with (192.168.200.1). If your pings are successful, congratulations, you just created a secure tunnel over the internet and created a foundational component to a hybrid environment.

Feel free to tinker with your new secure tunnel, maybe install traceroute and give that a try to see how your packets traverse or check out monitoring on the Azure side, the world is yours to explore!

Troubleshooting

I came across a few issues when configuring the connection, below are some steps that can be useful for troubleshooting your site-to-site VPN.

Cleanup

Once you are done tinkering, be sure to delete your resource group to avoid any costly bills. Hope you enjoyed this one and learned something valuable in this lab. 🙌