Configure an Always On VPN user tunnel

The Always On feature was introduced in the Windows 10 VPN client. Always On is the ability to maintain a VPN connection. With Always On, the active VPN profile can connect automatically and remain connected based on triggers, such as user sign-in, network state change, or device screen active.

You can use gateways with Always On to establish persistent user tunnels and device tunnels to Azure.

Always On VPN connections include either of two types of tunnels:

  • Device tunnel: Connects to specified VPN servers before users sign in to the device. Pre-sign-in connectivity scenarios and device management use a device tunnel.

  • User tunnel: Connects only after users sign in to the device. By using user tunnels, you can access organization resources through VPN servers.

Device tunnels and user tunnels operate independent of their VPN profiles. They can be connected at the same time, and they can use different authentication methods and other VPN configuration settings, as appropriate.

This article helps you configure an Always On VPN user tunnel. For information about configuring a device tunnel, see Configure an Always On VPN device tunnel.

Configure the gateway

Use the instructions in the Configure a Point-to-Site VPN connection article to configure the VPN gateway to use IKEv2 and certificate-based authentication.

Configure a user tunnel

  1. Install client certificates on the Windows client, as shown in this point-to-site VPN client article. The certificate must be in the current user store.

  2. You can configure the Always On VPN client through PowerShell, Configuration Manager, or Intune by following the instructions in Configure Windows 10 or later client Always On VPN connections.

Example configuration for the user tunnel

After you've configured the virtual network gateway and installed the client certificate in the local machine store on the Windows client, configure a client device tunnel by using the following examples. Note that these examples have been validated on Windows 10.

  1. Copy the following text, and save it as usercert.ps1:

    $a = Test-Path $xmlFilePath
    echo $a
    $ProfileXML = Get-Content $xmlFilePath
    echo $XML
    $ProfileNameEscaped = $ProfileName -replace ' ', '%20'
    $Version = 201606090004
    $ProfileXML = $ProfileXML -replace '<', '&lt;'
    $ProfileXML = $ProfileXML -replace '>', '&gt;'
    $ProfileXML = $ProfileXML -replace '"', '&quot;'
    $nodeCSPURI = './Vendor/MSFT/VPNv2'
    $namespaceName = "root\cimv2\mdm\dmmap"
    $className = "MDM_VPNv2_01"
    $session = New-CimSession
    $newInstance = New-Object Microsoft.Management.Infrastructure.CimInstance $className, $namespaceName
    $property = [Microsoft.Management.Infrastructure.CimProperty]::Create("ParentID", "$nodeCSPURI", 'String', 'Key')
    $property = [Microsoft.Management.Infrastructure.CimProperty]::Create("InstanceID", "$ProfileNameEscaped", 'String', 'Key')
    $property = [Microsoft.Management.Infrastructure.CimProperty]::Create("ProfileXML", "$ProfileXML", 'String', 'Property')
    $session.CreateInstance($namespaceName, $newInstance)
    $Message = "Created $ProfileName profile."
    Write-Host "$Message"
    catch [Exception]
    $Message = "Unable to create $ProfileName profile: $_"
    Write-Host "$Message"
    $Message = "Complete."
    Write-Host "$Message"
  2. Copy the following text, and save it as VPNProfile.xml in the same folder as usercert.ps1. Edit the following text to match your environment:

    • <Servers></Servers> <= Can be found in the VpnSettings.xml in the downloaded profile zip file
    • <Address></Address> <= IP of resource in the vnet or the vnet address space
    • <Address></Address> <= IP of resource in the vnet or the vnet address space
    • <PrefixSize>32</PrefixSize> <= Subnet mask
     <EapHostConfig xmlns=""><EapMethod><Type xmlns="">13</Type><VendorId xmlns="">0</VendorId><VendorType xmlns="">0</VendorType><AuthorId xmlns="">0</AuthorId></EapMethod><Config xmlns=""><Eap xmlns=""><Type>13</Type><EapType xmlns=""><CredentialsSource><CertificateStore><SimpleCertSelection>true</SimpleCertSelection></CertificateStore></CredentialsSource><ServerValidation><DisableUserPromptForServerValidation>false</DisableUserPromptForServerValidation><ServerNames></ServerNames></ServerValidation><DifferentUsername>false</DifferentUsername><PerformServerValidation xmlns="">false</PerformServerValidation><AcceptServerName xmlns="">false</AcceptServerName></EapType></Eap></Config></EapHostConfig>
      <!-- disable the addition of a class based route for the assigned IP address on the VPN interface -->
       <!-- use host routes(/32) to prevent routing conflicts -->  
     <!-- traffic filters for the routes specified above so that only this traffic can go over the device tunnel --> 
     <!-- need to specify always on = true --> 
     <!--new node to register client IP address in DNS to enable manage out -->
  3. Run PowerShell as an administrator.

  4. In PowerShell, switch to the folder where usercert.ps1 and VPNProfile.xml are located, and run the following command:

    C:\> .\usercert.ps1 .\VPNProfile.xml UserTest


  5. Under VPN Settings, look for the UserTest entry, and then select Connect.

  6. If the connection succeeds, you've successfully configured an Always On user tunnel.

To remove a profile

To remove a profile, use the following steps:

  1. Run the following command:

    C:\> Remove-VpnConnection UserTest  
  2. Disconnect the connection, and clear the Connect automatically check box.


Next steps

To troubleshoot any connection issues that might occur, see Azure point-to-site connection problems.