Route traffic to/from specific hosts over VPN on Windows 7 client

vpnwindows 7

I have a VPN connection set up on my Windows 7 Pro machine. Currently accessing our SVN repos and bug tracking/etc sites I have to explicitly enable my VPN connection (killing my web connection).
I'd like to be able to route this automatically so that when trying to access these services (on two servers accessed by hostname) it will correctly route over VPN.

Another catch-I don't want this to happen when I'm physically on the LAN these machines are on.

Any pointers? Thanks 🙂

Best Answer

I think this mostly depends on the private network your SVN and other resources are located on.

If you specify only to route traffic for that particular private subnet through the VPN, then you can maintain your web sessions and have all other traffic route out your normal internet connection instead of the VPN tunnel, which is exactly how permnanent VPN connections are routed in order to maintain their permanence.

This post speaks to your question somewhat and provides additional insight: https://superuser.com/questions/12022/how-can-i-make-the-windows-vpn-route-selective-traffic-by-destination-network

So to recap; On your VPN connection settings you need to make sure that 'Use Remote Gateway' is unchecked, because this effectively tells your local machine to send ALL traffic through the VPN tunnel and out the gateway of the remote network. The second thing you need to do is ensure routing of traffic bound for the resources in the private network gets to the other end of your VPN tunnel which will reach the resources there or can then be routed from that end-point. Some VPN clients have the ability to create these static routes automatically for you, otherwise you will need to manually enter that routing information on your local machine. As long as your local private network and the remote private network are numbered differently, you should be able to leave those routes in permanently, as opposed to what the post in the above link says.

To do this manually in Windows 7 your need know the network addresses for your local private network and the remote private network, the IP of the default gateway on the remote private network, and how to use the 'route' command in windows.