Add a static route to Windows

To add a static route to windows you can use the route command:

To view the existing routes on a machine. Open a command prompt and type the following:

route print

To add a static route:

route add <target> mask <netmask> <gateway IP> metric <metric cost> if <interface>

eg. route add 192.168.1.0 mask 255.255.255.0 10.10.1.1 metric 1

The above static route will only be available till the machine in rebooted. To add a persistane route (one that lives after a reboot of the machine) add the -p switch to the command.

eg. route -p add 192.168.1.0 mask 255.255.255.0 10.10.1.1 metric 1

The following registry key holds the values for static routes.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\PersistentRoutes

As with other command prompt commands you can view all the options this command offers by typing route /? at the command prompt.


Share

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment