Labels

Monday, January 28, 2013

HowTo: Adding a Static Route in Windows

To view the existing routes,
    C:\> route print

To add a static route,

    Syntax:
    C:\> route add <target> mask <netmask> <gateway IP> metric <metric cost> if <interface>

    Example:
    C:\> route add 10.10.10.0 mask 255.255.255.0 192.168.1.1 metric 1

Note: If there is more than one Network Interface and if the interface is not mentioned, the interface is selected based on the gateway IP.

This Static route gets erased when the system reboots. To avoid this, use the -p (Persistent) switch to the above command:
   
    C:\> route -p add 10.10.10.0 mask 255.255.255.0 192.168.1.1 metric 1