Friday, December 3, 2010

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

SkyHi @ Friday, December 03, 2010
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


REFERENCES

http://www.windowsreference.com/windows-2000/how-to-add-static-route-in-windows-xp2000vista/