This week, I set out to re-connect my Draytek Vigor 2927 router to an Azure Virtual Network using a site-to-site VPN. While the process had a few challenges, the end result was a simple reliable connection between my on-premises network and Azure.
In this post, I’ll walk through the main steps, highlight a few tips, and share the Powershell commands I used once the Azure Powershell module was installed.
In this brief outline I am only attempting to create an IPsec site-to-site VPN tunnel using a preshared key, alternative steps are required to use an X.509 certificate for authentication.
Today, it is only possible to deploy the lowest cost ‘Basic’ SKU VPN Gateway in Azure using command line tools, and this gateway type requires a Basic public IP address. Coming up, in September 2025 only Standard IPs will be available for deployment, so this guide will likely need to be revised.
NB This guidance should only be followed in a test or lab environment where you can control the networking outcomes caused by reconfiguring your equipment and restarting it where necessary. Use with caution.
Step 1: Install and Connect Azure Powershell
Before running any commands, make sure the Azure Powershell module is installed. If not, you can do it with:
Install-Module -Name Az -AllowClobber -Scope CurrentUser
Once installed, open Powershell and log in to your Azure account:
Connect-AzAccount
Select the correct subscription if you have multiple under your tenant.
Step 2: Define initial Powershell variables
Based on my example values, define the variables which you will need during the process, at minimum you will need to replace the location, subnet prefix, local network prefix and preshared key:
$rg = 'SBC-Infrastructure-PAYG' #This is the resource group where the new resources will be created
$location = 'UK South'
$publicIpName = 'pubip-sbcvpngw1'
$vnetName = 'sbcazurevnet'
$subnetName = 'GatewaySubnet'
$subnetPrefix = '172.20.0.0/24' #This is my Azure VNet’s network range, not the Gateway subnet range
$gatewayName = 'vpngw-sbcvpngw1'
$gatewaySku = 'Basic'
$lngRouterName = 'lng-sbcrouterip1'
$lngRouterIP = '80.xx.yy.zz' #This is my on-premises Draytek router’s public IP
$lngSubnetPrefix = '192.168.0.0/24' #This is my on-premises network range
$preSharedKey = 'yourpresharedkey'
Step 3: Set Up the Azure Virtual Networking elements
After logging in, create the required resource group, virtual network, and gateway subnet. Replace the variable values as needed for your environment.
Create a new resource group for the VPN gateway:
New-AzResourceGroup -Name $rg -Location $location
Create a new public IP address in the resource group:
$gwip = New-AzPublicIpAddress -Name $publicIpName -ResourceGroupName $rg -Location $location -AllocationMethod Dynamic -Sku Basic
Create a subnet in the virtual network for the VPN gateway:
$subnet = New-AzVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix $subnetPrefix
Create a new virtual network before creating the VPN gateway (if it doesn’t exist):
$vnet = New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rg -Location $location -AddressPrefix "172.20.0.0/16" -Subnets $subnet
If you have already implemented a VNet, subnet and public IP address and want to retrieve those objects you can follow the sub-step below to populate them using Powershell (this is a good way to validate all of your variables):
Retrieve the virtual network and subnet to ensure they are correctly set up:
$vnet = Get-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rg
$subnet = Get-AzVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -VirtualNetwork $vnet
$gwip = Get-AzPublicIpAddress -Name $publicIpName -ResourceGroupName $rg
Step 4: Create the VPN Gateway
Now you can create the VPN gateway with a basic SKU and route-based IPv4 configuration
$ngwIpConfig = New-AzVirtualNetworkGatewayIpConfig -Name "GatewayIpConfig" -Subnet $subnet -PublicIpAddress $gwip
$azvng = New-AzVirtualNetworkGateway -Name $gatewayName -ResourceGroupName $rg -Location $location -IpConfigurations $ngwIpConfig -GatewayType "Vpn" -VpnType "RouteBased" -GatewaySku $gatewaySku
Note: Creating a gateway can take up to 45 minutes, however in my recent experience this can be something around 10 minutes. Be patient!
Once the command has run to completion you should have a variable containing the detail of the virtual network gateway, however if you need to recreate it run:
$azvng = Get-AzVirtualNetworkGateway -Name $gatewayName -ResourceGroupName $rg
Step 5: Configure the Local Network Gateway
Create a local network gateway which defines the connection target for your on-premises router
$azlng = New-AzLocalNetworkGateway -Name $lngRouterName -ResourceGroupName $rg -Location $location -GatewayIpAddress $lngRouterIP -AddressPrefix $lngSubnetPrefix
Otherwise, you can retrieve an existing local network gateway using
$azlng = Get-AzLocalNetworkGateway -Name $lngRouterName -ResourceGroupName $rg
Step 6: Establish the VPN Connection
Create a VPN connection between the Azure VPN gateway and the local network gateway (this is a multi-line command)
New-AzVirtualNetworkGatewayConnection -Name conn-AZ-to-SBC-vpn -ResourceGroupName $rg `
-Location $location -VirtualNetworkGateway1 $azvng -LocalNetworkGateway2 $azlng `
-ConnectionType IPsec `
-SharedKey $preSharedKey `
-ConnectionProtocol IKEv2
Step 7: Configure the Draytek Vigor 2927
On the Draytek side, log in to the router web interface and configure an IPsec VPN profile.
Input the pre-shared key, remote gateway (Azure’s public IP), and remote subnets as configured above. Use the correct proposal algorithms for compatibility (usually AES256/SHA256 and DH Group 2 for Azure).
These screen elements relate to the latest firmware at time of publishing (V2927_20250804_DrayTek_4462).
It is very important to complete/validate the first step because enabling the IPsec VPN service requires a reboot, and whilst this may have been done previously there’s no way to know if you will be able to make a new tunnel until it is enabled then rebooted.
Here are the exact configuration elements which I finally validated successfully:
- Open VPN and Remote Access > Enable IPsec VPN Service (reboot required otherwise no tunnel will be established)
- Open VPN and Remote Access > LAN to LAN > Add (new profile)
- Set the following Common settings:
- Enable this profile: Yes
- Name: Azure_VPN_tunnel
- Set the following Dial-Out settings:
- Call direction: Both
- Dial out through: WAN1
- Dial out settings:
- IPsec tunnel: IKEv2
- Server IP/Host Name: IP address or name of the local network gateway (e.g., lng-sbcrouterip1)
- IKE phase 1 settings:
- Authentication method: Pre-shared key
- Pre-shared key: yourpresharedkey
- Proposal Encryption: AES-256
- Proposal DH Group: Group 2 (1024 bit)
- Proposal Authentication: SHA-256
- IKE phase 2 settings:
- Security protocol: ESP (High)
- Proposal Encryption: AES-256
- Proposal Authentication: SHA-256
- IKE Advanced settings:
- Phase 1 Key lifetime: 28800 seconds
- Phase 2 Key lifetime: 3599 seconds
- Enable Perfect Forward Secret: Not checked
- Set the following Dial-In parameters:
- Allowed VPN Type: IPsec Tunnel(IKEv1/IKEv2)
- Specify Remote VPN Gateway:
- Remote IP address: (e.g. public IP of the Azure VPN gateway)
- Allowed IKE Authentication Method:
- Pre-shared key: yourpresharedkey
- Allowed IPsec Security method:
- AH, ESP-DES, ESP-3DES, ESP-AES
- TCP/IP Network Settings:
- Local Network IP: 192.168.0.0
- Local Network mask: 255.255.255.0
- Remote Network IP: 172.20.0.0
- Remote Network mask: 255.255.0.0
