4

I'm trying to better undstand how traffic is routed through a VPN on a windows machine.

I have a working vpn server at work that I am connected to from home. My networks subnet is 192.168.8.x

The vpn server's subnet is 192.168.1.x

If I right click on the established vpn connection and look at the connection details there is no default gateway listed for the network interface. Just an ip address, subnet mask, and DNS.

My understanding is that if you try to access any IP address that is outside your own subnet it then tries to get routed through a default gateway.

I figured with a VPN you simply would have two defaults gateways and your computer would just try both.

I'm obviosly very confused as to how this all works and would like to know how it is that if I type in 192.168.1.1 I get the router on the remoute network (VPN side) while i'm on a 192.168.8.x subnet...

3 Answers 3

3

My understanding is that if you try to access any IP address that is outside your own subnet it then tries to get routed through a default gateway.

Essentially correct. You use the default gateway if you don't have a more specific route to the destination. The default gateway is the "catch all" and should point to the router that provides you with Internet access.

I figured with a VPN you simply would have two defaults gateways and your computer would just try both.

That would work very, very poorly.

A VPN will only be your default route if it's intended to provide your Internet access. If it's just intended to provide you access to specific subnets on the other side of the VPN, then specific routes will be used to just those subnets, over the VPN.

3
  • So what happens when I tell windows to go to an IP address and I have two NICs present. How does it know which one to choose, does it try both? I know that the 192.168.0.0/24 subnet is reserved for local networks, does that play a role in routing in determing wether an address gets routed or is out to local address first? I guess I had in my mind that there was a golden rule that machines on different subnets couldn't talk to each other, unless a router was involved. Yet somehow I can access another subnet using my VPN. Just wondering what mechanisms are involved.
    – Greg G
    Jul 6, 2014 at 14:47
  • @GregG Checking the routing table as suggested in my answer will give you an idea. Any address of the form 192.168.8.x will go through your regular network.
    – vfclists
    Jul 6, 2014 at 18:10
  • @GregG It does not try both. It picks the one that is the "closest" to the IP address you are trying to reach, based on the routing table. Jul 6, 2014 at 23:19
2

The VPN you setup must have been automatically configured as your default route to the internet.

If you are using Windows executing route print on the Command Prompt will display your routing table. For Linux the command will be route -n.

The gateway value on the lines whose destination is 0.0.0.0 shows you the device and network through which your internet connection is routed.

If there is more than one line with 0.0.0.0 as the destination, the one with the lower metric value takes precedence.

I suspect that in your case the VPN uses a lower metric value than your regular network. In that case you need to set the metric value of the VPN network to a higher value than your regular network.

-2

When you initiate a VPN connection the client software on the server establishes the secure connection, grants the remote user access to the internal network and—bing, bang, boom!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .