7

Can I add a static route to a VPN network if the default gateway IP is dynamic? (Windows 7)

This is easy to solve with a permanent route if the default gateway does not change as you can do this:

route add 10.0.0.0 mask 255.255.255.0 192.168.117.232 -p

However the VPN created by our customer's firewall assigns a dynamic IP address for the VPN's default gateway and as such, the last block of the IP can change.

Is there any way to do this via adapter only? Or using an IP range?

3 Answers 3

14

I've found out the answer myself:

You don't actually need to specify the default gateway - you can use the catch-all of 0.0.0.0 and then specify the interface number instead (the docs do not make this obvious!):

  1. Find the interface number of the VPN by running "route print" from the command prompt and use this for the IF argument in the command below.

  2. Add a static route for the IP range concerned using "route add" (with -p to make it permanent):

    route add x.x.x.x mask 255.255.255.0 0.0.0.0 IF yy -p

Of course - you need to replace the IP address (x.x.x.x) and interface number (yy) in the command above with those relevant to your system.

Thankfully the VPN interface ID doesn't seem to change when you reconnect but it will be different from computer to computer.

"route print" should then show the desired static route with the gateway address as "On-link":

===========================================================================
Persistent Routes:
  Network Address          Netmask  Gateway Address  Metric
         10.0.0.0    255.255.255.0         On-link        1
===========================================================================
1
  • Nice, it looks ugly and terrible not scalable, but good job. Jun 5, 2015 at 12:50
1

The marked answer isn't valid when you have more than one VPN configured on the client.

Windows will assign a different number to the Interface of the VPN depending on which one you start first.

Let's say you have two VPN connections. They get assigned the IF number 38 if you only launch one of them. But if you launch both, one will get number 38 and the other will get number 39.

The first one to launch will be the one that gets the lower number.

0

IHMO I don't think that there is anything you can do without proper configuration of the VPN concentrator, except some scripting. Things like pushing routes to client may be solved by (and are usually solved by) pushing routes via:

2
  • Actually I've just figured out. See my answer. It can also be done using DHCP provided routes, but it seems this would require Windows 8+ and is not supported by Windows 7.
    – NickG
    Jun 5, 2015 at 12:40
  • What problems have you got with Windows 7? Jun 5, 2015 at 12:53

You must log in to answer this question.

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