Subscribe Subscribe | Subscribe Comments RSS
Subscribe in Bloglines

Add to netvibes
Add to Google Reader or Homepage

As with the Unix,Linux and Solaris operating Systems, the route command can be used to add static routes in Windows. This should work on Windows 2000,XP,2003.

Windows Route Print command 

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

This writes the persistent route to the following Windows Registry key as a string value (REG_SZ):

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

Also, you can write a small batch file with the route commands and add it to the startup folder to add the routes at startup (similar to the startup scripts in Solaris)

For more options like flushing the IP Routing table or to delete, modify IP Routing table entry use the route command with no arguements. This displays the various options for the route command.

C:\> route

This should help.

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

11 Comments so far »

  1. by Hady Marzuki, on July 27 2008 @ 9:48 am

     

    Just the info that I need. Thx.

  2. by Chris, on August 18 2008 @ 11:50 am

     

    Very helpfull. Thanks

  3. by Kullit, on August 31 2008 @ 10:10 pm

     

    please email me if i want to add static password for singale ip, my compuetr ip is 192.168.4.1 and want to route this 192.168.0.1. how can i do that?

  4. by Rick, on October 29 2008 @ 4:36 pm

     

    Great Infomation, Thank you.

  5. by Nagilum, on December 31 2008 @ 10:17 am

     

    Thanks for that hint!
    Could have found that myself… but I didn’t read the full info/output. ;)

  6. by newbie2010, on September 8 2010 @ 7:54 am

     

    I have one remote branch with an IP address of 192.168.4.2 netmask 255.255.255.0.GW is 192.168.4.1 What is the best syntax or routing command for me to ping interanal client pc such as 192.168.16.5 from our head office? My Head office had a MODEM 192.168.0.1 LAN ip, and its directly connected to a router with 192.168.16.3 LAN IP. Using 192.168.16.5 pc, I cant ping remote modem 192.168.4.1 modem but no luck to 192.168.4.2 pc.Any helpfull advice?

  7. by Multiple internet connections - some advice, on September 16 2010 @ 6:14 am

     

    […] server routing table that points those specific ip addresses out via the secondary provider router HowTo: Add persistent Static Routes in Windows | ItsyourIP.com route -p add 10.10.10.0 mask 255.255.255.0 192.168.1.1 metric 1 in your scenario you would […]

  8. by Jack Burch, on January 7 2011 @ 2:22 pm

     

    Fantastic. The information got my job done.

  9. by AD, on May 25 2011 @ 8:17 am

     

    Thanks for the help… I had added a route without taking the print earlier and was then unable to connect to the network. I checked the files in winnt\system32\drivers\etc files but did not find anything.
    But I know where I should search (registry entries of course)!!!

  10. by This is regarding Static routes - Just just easy answers, on September 6 2013 @ 2:34 am

     

    […] can also put a static route on your specific system. Again, this is OS specific, but there this web page describes how to do it with […]

  11. by BranchCache – Hosted Cache Mode File Server Tutorial | theezitguy, on July 3 2014 @ 10:31 am

Comment RSS · TrackBack URI

Leave a comment

Name: (Required)

eMail: (Required)

Website:

Comment: