I am using VPN service to access some work from abroad. Sometimes my VPN connection drops and my computer automatically connects to my local connection, which I do not won't as it immediately discloses my actual IP. The VPN service provider's support could not help me. Is there anyway to block my computer from reconnecting to my local connection?

2 Answers 2


To elaborate on Zoredache's answer, your problem can be solved by changing your routing configuration. I'll provide examples for Windows.

Collecting Information

Step 1: Description and Default Gateway

Firstly, you need to determine your local connection's Description and Default Gateway. Open up a command prompt (Start -> Run... -> cmd) and then run ipconfig /all. You will see output similar to the following:

Windows IP Configuration

Ethernet adapter Local Network Connection:
   Description . . . . . . . . . . . : Intel(R) 123BBQ Network Connection
   Physical Address. . . . . . . . . : 12-FE-34-DC-56-BA
   IPv4 Address. . . . . . . . . . . :
   Subnet Mask . . . . . . . . . . . :
   Default Gateway . . . . . . . . . :


Note that if you are connecting to your ISP first, (Eg. via a PPPoE connection where you enter a username and password), you will need to look for something like PPP adapter <Connection Name>: instead. In this example, the Description is Intel(R) 123BBQ Network Connection and the Default Gateway is

Step 2: VPN End Point IP Address

Next, you need your VPN end point's IP address. You mention that you use a VPN service provider. If your VPN connects to a hostname (Eg. vpn1.serviceprovider.com), you can determine the IP address by running ping vpn1.serviceprovider.com in the command prompt (nslookup may also be used):

Pinging vpn1.serviceprovider.com [] with 32 bytes of data:
Reply from bytes=32 time=50ms TTL=55

In this example, the VPN end point IP is

Step 3: Interface Number

Lastly, you need your local connection's interface number. Run route print x (x is a bogus filter so you don't see much more than the interface list) in the command prompt:

Interface List
 11...12 fe 34 dc 56 ba ......Intel(R) 123BBQ Network Connection
  1...........................Software Loopback Interface 1

The interface number is the first number on the line, and you need to find the line that has the same description as in our first step. In this example, Intel(R) 123BBQ Network Connection has an interface number of 11.

Setting It All Up

Disabling Routing

Once you have all this information, and after you are connected to your VPN, run the following in the command prompt:

route add <VPN end point IP> mask <Local connection's Default Gateway> metric 1 if <Local connection's interface number>
route delete if <Local connection's interface number>

Eg: route add mask metric 1 if 11
Eg: route delete if 11

This will remove the default route from your local connection, and replaces it with a single route directly to your VPN end point. Now, when your VPN connection drops, there is no route for traffic to reach the internet, so your IP address won't be exposed.

Re-enabling Routing

To restore your local connection's default route, you can run the following in the command prompt:

route add mask <Local connection's Default Gateway> metric 1 if <Local connection's interface number>

Eg: route add mask metric 1 if 11

You may need to do this in order to reconnect to the VPN if your VPN connects to a hostname, or if you simply want to stop using the VPN.

Saving Time

If your VPN end point IP address never changes (Your VPN service provider may be able to tell you whether this is the case), you can even save the completed commands to files ending in .bat, (Eg. disablerouting.bat and enablerouting.bat). That way, double-clicking on the files will run the commands without you having to type them in every time.


Remove the default route and create a route specifically to reach you VPN provider. The excact syntax is different for each OS. But it looks linda like this.

route del 0/0
route add vpnserverip/32 via localgw

You must log in to answer this question.

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