Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What routes do I have to set on Windows so that while using OpenVPN I have full Internet connectivity, but if OpenVPN tunnel collapses then my computer has no routes to use and thus has no connectivity.

My computer normally needs the default route mask I just need a route that only allowed traffic destined for the OpenVPN server's IP. The traffic has to go through, however, as that is my home network's Internet gateway router thingy.

share|improve this question

You can't do it. It is impossible. What is a VPN? It is a virtual network that is tunneled across the internet. This means in order to actually establish the VPN you first need internet access. If you remove your "normal internet" route and try to force all traffic down the VPN it will fail because the VPN can't even be established because there is no internet.

What came first, the chick or the egg?

ummmm actually I just had an idea how to get this working "in theory". I'm a genius if this works, modest aren't I? Let me know if it does ;-)

Change your default gateway on your PC to be the private IP address of the VPN server. Now you need to know the public IP address of the VPN server you connect to and modify your routing table. Hard to explain without an example so here it is.

Your local IP range is 192.168.1.x and your default gateway (router) is

When you connect to the VPN server you connect on (public IP). Once connected it assigns you an IP of and changes your default gateway to the VPN servers private IP of (this change means all internet traffic is now routed through the VPN server). This gives us the information needed to configure your PC now how you want to. Disconnect the VPN.

Now edit your TCP/IP settings and change the default gateway to (so all internet traffic is routed through the VPN server). All internet traffic will now fail unless the VPN is up. Now open a command prompt and type the following:

route add mask metric 1 -p

This add a static route to your windows PC which will override the default gateway only when you try to connect to (your VPN server). When it matches this entry it will go out your router ( onto the internet normally. This one rule will allow the VPN to be established then all other traffic will go across the VPN.

Note: when setting the default gateway you will get a warning about it being on a different subnet, just accept it and contine.

I have never done this so i can't say it will definitly work but I know a lot about routing and from the "rules" of routing this should work for you. If it does please up vote this answer as it is actually quite difficult to work this out and I doubt you will find this solution anywhere else.

EDIT: I tested this when I got home and I was right, it can be done this way ;-)

share|improve this answer

You must log in to answer this question.

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