How to Add Static route in Windows XP/2000/Vista

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


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

  • Share/Bookmark

Random Posts


Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically each day to your feed reader.

Trackbacks & Pingbacks

No trackbacks/pingbacks yet.

Comments

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

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”

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.

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.

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

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

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

(required)

(required)