Jan 182008
 


A route describes the gateway IP address and network interface to use when sending packets to a network. The routing table on a host holds a list of destination networks and the routes to those networks. This recipe describes adding entries to this routing table that will not persist following a reboot. These temporary routes are useful during troubleshooting or when making changes to the network topology.

If you want to add static route you need to use route command

route syntax

route [-f] [-p] [Command [Destination] [mask Netmask] [Gateway] [metric Metric]] [if Interface]]

-f : Clears the routing table of all entries that are not host routes

-p : When used with the add command, the specified route is added to the registry and is used to initialize the IP routing table whenever the TCP/IP protocol is started.

Command : Specifies the command you want to run.

add

change

delete

print

mask Netmask : Specifies the netmask

Gateway : Specifies the forwarding or next hop IP address over which the set of addresses defined by the network destination and subnet mask are reachable.

metric Metric : Specifies an integer cost metric (ranging from 1 to 9999) for the route, which is used when choosing among multiple routes in the routing table that most closely match the destination address of a packet being forwarded.

if Interface : Specifies the interface index for the interface over which the destination is reachable.

Examples

To display the entire contents of the IP routing table, type:

route print

To display the routes in the IP routing table that begin with 10., type:

route print 10.*

To add a default route with the default gateway address of 192.168.12.1, type:

route add 0.0.0.0 mask 0.0.0.0 192.168.12.1

To add a route to the destination 10.41.0.0 with the subnet mask of 255.255.0.0 and the next hop address of 10.27.0.1, type:

route add 10.41.0.0 mask 255.255.0.0 10.27.0.1

To add a persistent route to the destination 10.41.0.0 with the subnet mask of 255.255.0.0 and the next hop address of 10.27.0.1, type:

route -p add 10.41.0.0 mask 255.255.0.0 10.27.0.1

To add a route to the destination 10.41.0.0 with the subnet mask of 255.255.0.0, the next hop address of 10.27.0.1, and the cost metric of 7, type:

route add 10.41.0.0 mask 255.255.0.0 10.27.0.1 metric 7

To add a route to the destination 10.41.0.0 with the subnet mask of 255.255.0.0, the next hop address of 10.27.0.1, and using the interface index 0×3, type:

route add 10.41.0.0 mask 255.255.0.0 10.27.0.1 if 0×3

To delete the route to the destination 10.41.0.0 with the subnet mask of 255.255.0.0, type:

route delete 10.41.0.0 mask 255.255.0.0

To delete all routes in the IP routing table that begin with 10., type:

route delete 10.*

To change the next hop address of the route with the destination of 10.41.0.0 and the subnet mask of 255.255.0.0 from 10.27.0.1 to 10.27.0.25, type:

route change 10.41.0.0 mask 255.255.0.0 10.27.0.25

Incoming search terms:

  18 Responses to “How to Add Static route in Windows XP/2000/Vista”

  1. I’ve always wondered HOW exactly one is to determine the interface index, and WHY exactly microsoft decided to implement their rout command in such a silly way as to require it….have yet to see an answer to those questions on any website

  2. XP can choose the right interface by using the gateway you gave in the route command.

    However, to get interface index just type “print route” at the command prompt and read the interface index from the interface list which will be printed. (Dont include the quotes!)

    Step by Step Instructions:
    1. Click Start button and then select run
    2. Type command
    3. At the command prompt, type “route print”

  3. I am connecting to internet over the wireless and connecting to my lan over the local connection. The Ip assigned to my internet modem already exist on my Lan and cannot be changed and my ISP also insisted that they cannot change the ip on the modem. What do i do to solve this problem. what i do right now is I remove the lan cable to be able to use internet and vice versa. But that is too tasking.

  4. The “route” command is a powerful command however many users will find it challenging if used with vista, not because it is a difficult task, but because vista requires you to be something more than an administrator.

    Another reason why Vista is crap.

  5. I was wondering how you make this permanent, like so i don’t have to type it every time i startup my computer.

  6. Scott. Type a /p at the end to make it persistant

  7. Just a couple of corrections:
    To see the current routes on a Windows computer use:
    route print (not print route)
    To make a route entry permanent (persistent)
    use a -p just after the word route in the command
    (not /p)
    example:
    route -p ADD 172.16.8.0 MASK 255.255.255.0 192.168.1.1

  8. I am trying to add routes to a bridge interface in a Windows 7 machine as the routes for the non-shared link dont appear without some assistance despite the info I have found to date which states the contrary. It adds the shared interface connection as a default route but not the other link which ensures traffic returning down that link is not getting there. I have tried configuring an IP address from the non-shared link network on the bridge interface itself. This allows traffic from the bridged device down the non-shared link but devices at the end of this link initiate and pass through the bridged connection to use the shared link due to no return path to them appearing in the bridging devices route table.

    So manually trying to add a route to the non-shared link after entering the following command I get the following message and no action:

    route -p ADD 192.169.1.0 MASK 255.255.255.0 192.168.1.1
    The requested operation requires elevation.

    Would appreciate any suggestions on what it is suggesting I do. Or if I am barking up the wrong tree completely… Thanks

  9. Dear All,

    Windows 7 issue is resolved. We are now able to add multiple static route in windows 7.

    I found the process in the below link:

    http://gaskell.org/the-requested-operation-requires-elevation-in-windows-vista/

  10. Click with the right button on the “Command Prompt” icon, then select “Run as Administrator”

  11. “Some One” – route print * gives the interface indexes at the top.

  12. The above are much helpful.

    I have an environment which need gateway to be 0.0.0.0.
    How to add it as the persistent route.

    Destination : 10.2xx.xx.x
    mask – 255.255.255.128
    gatway – 0.0.0.0

    How to achieve this?

  13. ip address- 10.10.63.23

    subnet mask- 255.255.255.0

    gateway- 192.168.1.1

    how to route add

  14. Hi,

    i have this funny messages popping up if i route add an ip in windows vista.
    please can you help me with command.

  15. I have Connected 2 Networks in my Laptop

    Wireless Network Card – 10.24.2.20,255.255.255.0,10.24.2.254
    Lan card – 10.101.1.104 , 255.255.255.0 , 10.101.1.1

    When i connected simultaneously i cant ping one of the netowrok , so how can add a route ,
    Please do explain about Metric value and interface

    Regards
    Sudeep
    09958715135

  16. i type the same command but its not working
    route add 192.168.220.2 255.255.255.248 192.168.218.130 metric 2 but it will display bad argument 192.168.218.130
    suggest me
    since my lan network is on 192.168.218.0/24 and getway ip is 192.168.218.130

    • You forgot the “mask” command:

      You had: route add 192.168.220.2 255.255.255.248 192.168.218.130 metric 2
      It should be: route add 192.168.220.2 mask 255.255.255.248 192.168.218.130 metric 2

  17. I think I am close but can’t quite get there.
    I have AT&T U-verse with its “Residential Gateway” at 192.168.1.254. It has limited physical LAN ports and can’t seem to handle more than 5 WiFi connections at once. So I have 2 routers connected the the LAN ports of 192.168.1.254. One router is for kids gaming, laptops, DVD, TV, etc. The 2nd router is for my home business.
    192.168.1.254
    / \
    192.168.2.1 192.168.3.1

    I would like to reach PCs and a printer on 192.168.2.x network via 192.168.3.x network
    In Windows 7 on 192.168.3.x network I added the following route but still cannot ping/reach the 192.168.2.x network
    route -p add 192.168.2.0 mask 255.255.255.0 192.168.1.254

    I tried several variations of the above command and cannot reach 192.168.2.x network.

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>