Friday, May 17, 2024
HomeWindowsWindows networkingNT/2000/XP: Add a Temporary Route to the Windows Routing Table

NT/2000/XP: Add a Temporary Route to the Windows Routing Table

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 tutorial 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.

To add a route to the network (corresponding to a subnet mask of through the gateway, use the following command:

route add mask

This is the simplest method of adding a temporary route. The subnet mask parameter is optional and defaults to which specifies that the target is a single IP address instead of a network.

An optional routing metric can be added to the route command for more complex situations. The metric can be considered a cost for using the route. If a routing table contains multiple routes to the same destination, the cheapest route (lowest cost or metric) will be used. To add a route with a metric of 10 to the host through the gateway, use the following command:

route add metric 10

In this case, the subnet mask is not given so the command defaults to the mask

Using names instead of numbers for the gateway and subnets is possible. If you use a name for the gateway, the name is looked up in the hosts file ({windows_home}\system32\drivers\etc\hosts) and the corresponding IP address is used. Named subnets will be looked up in the networks file ({windows_home}\system32\drivers).

If multiple network interfaces are available to route to the same destination, the interface can be specified in the route command. The interface number associated with the interface is shown using the route print command. Windows will automatically guess which interface is most appropriate for the given route. If you are dissatisfied with the guess Windows makes, the optional if {interface} parameter can be used. To specify that the previous route example should use interface 2 (identified with the hexadecimal value 0x2 in the route print command), use the following command:

route add metric 10 if 2

Quinn McHenry
Quinn McHenry
Quinn was one of the original co-founders of Tech-Recipes. He is currently crafting iOS applications as a senior developer at Small Planet Digital in Brooklyn, New York.


Please enter your comment!
Please enter your name here

Most Popular


Recent Comments

error: Content is protected !!