Understanding Client Address Pool & On-link Routing in Azure P2S VPN

Sriram Ganesan 136 Reputation points


Network Setup-
A simple Hub and Spoke model with the VPN Gateway configured with path based routing hosted in the hub network. A couple of spoke networks that are peered to the hub. P2S connections are established from a couple client machines to the Azure Network.
Address details-
Hub Vnet -
Spoke 1 Vnet -
Spoke 2 Vnet -
Address Pool assigned to the P2S connection clients -
A VM hosted in the Spoke 1 -

A similar setup is shown in the attached image.

When I connect to the VPN from a windows machine, the client receives an address from the pool, say
When I do a basic ping test (after enabling ICMP) from the windows client to the VM in spoke 1, it works fine. This confirms the correctness of the setup.

When I check the routes in the windows client (using route print command),
IPv4 Route Table


Active Routes:
NetworkDestination Netmask Gateway Interface Metric 25 On-link 43 On-link 281 On-link 43 On-link 281 26

The Gateway in the route to the hub and the spoke networks from the windows client is marked as "On-Link".
Upon some reading from the following 2 articles, my understanding is that routes that don't need a gateway as the next hop will be marked as "On-Link"



The important piece of the answers,

it’s just a route that's directly reachable the NIC is in direct contact with it; on the same subnet. To explain a little further though: by contrast, the routes that have a gateway IP listed must be contacted through that gateway.

Also doing a tracert to the VM from the windows client shows just 1 hop and that is to the VM directly
Tracing Route to over a maximum of 30 hops
1 29ms 28ms 28ms
Trace complete

I understand the basic working of a VPN. The client machine is allocated an IP from the VPN server's address range. This is like virtually connecting the laptop to the cloud network so that it receives an IP from the same network.
However, the client's IP address is in range and the hub and spokes are in the and address ranges.
How is the direct connection to the VM in the spoke accomplished? The answers from the forum posts for "On-Link" state that it is as if the VM's NIC is in the same subnet as the network destination it is trying to reach.

Any help to understand this concept would be much appreciated.


Azure VPN Gateway
Azure VPN Gateway
An Azure service that enables the connection of on-premises networks to Azure through site-to-site virtual private networks.
835 questions
No comments
{count} votes

Accepted answer
  1. Sriram Ganesan 136 Reputation points

    I did some studying about the way that Azure handles the default routing between the multiple address spaces of a VNET. Refer to "Network" heading under the Default Routes section in this article for more information

    " Routes traffic between address ranges within the address space of a virtual network. Azure creates a route with an address prefix that corresponds to each address range defined within the address space of a virtual network. If the virtual network address space has multiple address ranges defined, Azure creates an individual route for each address range"

    So when multiple address spaces are configured for a VNET, Azure automatically adds a default route for each of the address spaces. You can check this by deploying a VM in one of the Vnet's subnet and check the "effective routes" from its Nic's properties. You would find default routes to the below stated with "Virtual Network" as the next hop.
    a) every other address space in the same VNET
    b) every other address space of the peered or connected VNETS

    The only tricky part is that when we configure the address pool for P2S connections, Azure creates and manages this as an additional address space of the Vnet. This would not be seen in the portal though. I did not try to check the same with PowerShell though.
    When the client connects to the VPN, it receives an IP from the configured address pool. Since Azure manages the routing between the multiple address ranges the client would be able to access the VM's in the same hub VNET and the peered VNETS directly (without any gateway or involving multiple hops)

    One quick test that I did to confirm my understanding -
    a) Configured the P2S client address pool as stated in the ques -
    b) Now tried to add a conflicting address space as a second one in the Hub Vnet -
    This operation resulted in an error because of the conflict of address spaces.

    One other post that talks about the working of routing when multiple address spaces (a more complicated one though)


    No comments

0 additional answers

Sort by: Most helpful