How do I make Windows XP VPN connect over a specific network adapter?

4

2

I currently have two network connections on my laptop:

  • A wireless connection to a LAN that is fast and allows internet traffic but not outgoing VPN connections.
  • A data dongle that is slow and expensive, but does allow me to make a VPN connection back to my office.

If I connect my VPN when only the data dongle is enabled everything works fine. I can then enable the wireless connection too and all traffic not destined for the VPN goes over the wireless connection.

However, if the VPN connection breaks and I try to reconnect it consistently fails to connect until I disable the wireless connection.

I am getting fed up with constantly having to disable and re-enable the wireless connection to bring back my VPN connection. Is there a way to force the VPN connection to be made only over the data dongle?

UPDATE:

I have tried fiddling with both interface priority and metrics, but the best I could manage was getting ALL traffic to go over the dongle which is no good. Netsh appears to be unreliable on XP and didn't work for me. Devcon (a tool from MS) did work but required a little effort to get the device ID (run "devcon hwids *" and search the output for the connection name). Route also didn't want to work for me.

In the end I put together a batch script using the information in harrymc's answer to stop my wireless, connect to the VPN (using rasdial), and restart the wireless:

devcon disable *DEV_0024*
rasdial <VPN Name> <username> * /domain:<domain>
devcon enable *DEV_0024*

Dan

Posted 2012-03-01T14:36:10.850

Reputation: 205

Answers

3

You could try to change the binding order of network adapters so that the dongle is first :

  • Click Start, click Run, type ncpa.cpl , and then click OK.
  • On the Advanced menu, click Advanced Settings, and then click the Adapters and Bindings tab.
  • In the Connections area, select the dongle
  • Use the up-arrow button to move the connection higher in priority.

If this is not enough, the same article shows how to change the interface metric. Make it higher on the wired connection than the wireless.

If this doesn't work, then I note that under newer versions than XP, one can't have two network adapters active at the same time, but in XP this might work. If both adapters are active and have Internet/LAN access with different IPs, then this is possible by using the route command to specify that the VPN IP address is on a route that is only supported by the wireless adapter.

If both adapters cannot be set both active at the same time, then what you ask for is simply made impossible by Windows itself. The most you could do is write scripts that will do the enabling of adapters for you.

One way of doing it is using the devcon command as shown in the article Enable/Disable Wireless Card from Command Line.

Another would be by using the netsh command :

netsh interface set interface <interface name> DISABLED / ENABLED

For example to disable an interface with its default name "Local Area Connection", run:

netsh interface set interface "Local Area Connection" DISABLED

To enable the interface, you'd then run:

netsh interface set interface "Local Area Connection" ENABLED

harrymc

Posted 2012-03-01T14:36:10.850

Reputation: 306 093

Thanks for this. Unfortunately the dongle was already at the top of the priority list. Changing the metric to 1 on the dongle did work, but it also caused all internet traffic to go over the dongle too :( – Dan – 2012-03-08T09:13:13.007

Manually setting both the wireless connection and the dongle to the same metric doesn't work either, whatever the order in the priority list. – Dan – 2012-03-08T09:22:48.610

I have added more info. – harrymc – 2012-03-08T10:17:20.547

Thanks, it seems that netsh is unreliable on XP so I had to use devcon to cobble something together. I'll add more details to the question later on. – Dan – 2012-03-08T11:40:33.047

Just to be clear, when I said that setting both adapter metrics the same doesn't work, I meant that I couldn't connect to the VPN with that configuration, not that anything new had gone wrong. – Dan – 2012-03-08T12:48:27.067

I saw that you tried the route command but try this if you haven't already. Connect to wireless and then connect to the internet with your dongle and determine your current dongle IP address. Next run route add <VPN IP> MASK 255.255.255.255 <dongleIP>. Try your VPN connection. If it works, I'll figure out how to get your dongleIP in a script. – Jeremy W – 2012-03-11T03:53:23.050

0

This should work but I can't test it from this computer.

Go to your Network Connections/Adaptor settings page from the Control Panel and find your VPN connection. Right click on it > Properties, click on IP v4 and then click Properties.

Then uncheck default gateway / change it from what you use for your WLAN, to your dondgle.

Amicable

Posted 2012-03-01T14:36:10.850

Reputation: 538

Thanks, but I don't have an IPv4 button/control in my VPN properties page? – Dan – 2012-03-01T16:16:04.247

What VPN client are you using and what options are listed on the VPN properties page? – Amicable – 2012-03-01T19:03:59.467

It's just a default Windows XP VPN connection, it has tabs for General, Options, Security, Networking, and Advanced – Dan – 2012-03-01T21:51:09.947