When you’re troubleshooting TCP/IP connectivity problems on a Windows network, you may need to investigate the current IP routing table and add or delete specific IP routes. Windows comes with a command-line tool called Route, which you can use to reveal and edit this type of information. Unfortunately, the Route tool is stuck in the DOS-based world of the command line, so it’s often overlooked or avoided.
To make the Route tool easier to use, I’ve moved it out of the command line and created the Route Utility, an HTML Application (HTA) that uses Windows Script Host and VBScript to provide a GUI front end. Using this interface to the Route command-line tool will save you both time and frustration when working with a routing table on a local system.
The Route Utility was designed for Windows XP, but it will work in all earlier versions of the Windows operating system. Just remember that the versions of the Route command in these earlier operating systems do not support the full set of parameters implemented by Windows XP’s Route command. For example, Windows 98’s Route command-line tool doesn’t provide the -p or the If parameters.
Let’s start with a quick overview of the Route command-line tool. Then, we’ll see how you can put the Route Utility to work.
Note: This information is based on a previously published article. The Route Utility and a PDF version of the article are available as a free download.
Be careful
You should use caution when using the Route command to modify the routing table because one little mistake can really mess up your network communications. And to top it all off, the error messages displayed by the Route command leave a lot to be desired.
The Route command-line tool
The Route command-line tool is designed to display and modify the entries in the local routing table. This allows you to view and alter the path that the network traffic on a particular system follows to get from one place to another.
The syntax for the Route command is:
Route [-f] [-p] [Subcommand] [Destination] [Mask Netmask] [Gateway] [Metric Value] [if Interface]
The -f parameter allows you to remove all gateway entries from the local routing table. However, it doesn’t remove host routes, the loopback network route, or the multicast route. When the -f parameter is used along with any of the subcommands, the table is cleared before the command is run.
The -p parameter allows you to add persistent routes to the routing table or to display persistent routes in the routing table. For example, if you were to use just the Add subcommand to add a route to the routing table, it would exist as a valid route for the current session only. As soon as you rebooted the system, the TCP/IP protocol would reinitialize and that route would disappear. However, if you use the -p parameter along with the Add subcommand, the route will be added to the registry and will become a persistent route. In other words, it becomes a permanent part of the routing table. When you use the -p parameter along with the Print subcommand, the report displays only the persistent routes.
The Route command provides a set of subcommands you can use to specify an action that the Route command should take. This set of subcommands includes Add, Change, Delete, and Print. The Add subcommand allows you to temporarily add a route to the routing table. You use the Change subcommand to modify an existing route in the routing table. The Delete subcommand allows you to remove a route from the routing table. Now the Print subcommand will provide you with a detailed report that shows the contents of the routing table. (When troubleshooting a TCP/IP connectivity problem, using the Print subcommand is a good place to start your investigation. I’ll go into a bit more detail on the Print subcommand in a moment.)
Each of these subcommands except the Print subcommand requires a Destination argument, which is the IP address specifying the network destination that is reachable via the gateway. When you specify a destination for the Print or Delete subcommands, you can use a complete address or a partial address along with a wildcard. For example, if you wanted to see or delete only those entries in the routing table that start with 192, you could use 192.* as the destination argument.
The Mask parameter allows you to specify, as an argument, a netmask address (or subnet mask) for the route. If you don’t specify a netmask address for the route, the default netmask address, 255.25.255.255, is used.
The Gateway argument stands alone, in that it is not preceded with an explicit parameter and allows you to specify the address that the route is to use for traffic going to the destination.
The Metric parameter is used to specify, as an argument, a metric (or hop count) for a particular route. The metric value is used to determine the preferred route to follow when there are multiple routes to a destination and specifies the maximum number of hops that should exist between the local system and the gateway. The available route with the lowest metric is used.
The If parameter is used to specify, as an argument, the index of the interface that the route is to use. You can use either decimal or hexadecimal values for the interface index. When the If parameter is omitted, the interface is determined from the gateway address.
The Print subcommand
As I mentioned, when troubleshooting a TCP/IP connectivity problem related to the routing table, the Print subcommand is a good place to start your investigation. When you use the Print subcommand, you’ll see a report similar to the one shown in Figure A.
Figure A
The Route Print command displays the current routing table on a local system.
At the top of this report, you’ll see the Interface List section, which contains the interface indexes for the Microsoft TCP Loopback adapter and, in the case of this example system, a 3Com Etherlink network adapter card. As you can see, these two adapters have interface indexes listed as hexadecimal values of 0x1 and 0x2, respectively.
The Active Routes section contains the routing table and provides insight on how the Route command’s parameters actually function. Since the destination is the ultimate goal of the routing table, here’s a closer look at the addresses listed in the Network Destination column. Table A explains each address in the Network Destination column from my example system.
Table A
Network Destination | Description |
0.0.0.0 | Default route (This route is used when no other route is found.) |
127.0.0.0 | Loopback address |
192.168.1.0 | Local subnet address |
192.168.1.102 | Network card address |
192.168.1.255 | Subnet broadcast address |
224.0.0.0 | Multicast address |
255.255.255.255 | Limited broadcast address |
In Figure A, the Netmask column shows a list of addresses that are applied to each Network Destination address. The Gateway column shows a list of IP addresses that act as the gateway for that route. The Interface column shows a list of IP addresses assigned to the network adapter that the route will follow when leaving the local system. The Metric column shows a list of the hop count between the local system and the gateway.
Downloading and installing the Route Utility
Once you download the RouteUtility.zip archive file, manually installing the application on your hard disk is easy. To do so, create a folder called Route Utility. Then, unzip the RouteUtility.zip archive file and copy the route.ico and RouteUtility.txt files to the Route Utility folder. The route.ico file provides the Route Utility with the icon it uses for the control menu and the taskbar. The RouteUtility.txt file is the main HTML application, but because many antivirus programs filter out HTA files, I have renamed it RouteUtility.txt. You must rename the RoutUtility.txt file to RouteUtility.hta before you can use the Route Utility program. Once you’ve renamed the file, simply double-click it to run the Route Utility program.
Using the Route Utility
Now that you have a pretty good idea of how the Route command works, let’s take a look at how you can save yourself both time and frustration by using the Route Utility GUI to easily configure and issue complex Route commands.
To launch the Route Utility, simply double-click on the HTA file. When you do, you’ll see its main dialog box, as shown in Figure B. As you can see, the Route Utility contains a check box for each of the Route command’s parameters. There are also text boxes in which you can type the appropriate set of octet values, as well as other decimal or hexadecimal values.
Figure B
The Route Utility’s dialog box has a check box for each one of the Route command’s parameters, as well as text boxes to allow you to enter the appropriate values.
What’s a set of octets?
Have you ever heard someone refer to an IP address as a set of octets and wondered what they were talking about? An IP address is presented in a decimal format sometimes called a dotted decimal number. This is a format that’s easy for us to read. However, our computers convert these dotted decimal numbers into binary format. For example, a typical dotted decimal number IP address such as this one:
192.168.115.125
looks like this in binary format:
11000000.10101000.01110011.01111101
In the case of this particular IP address, the conversion results in four sets of eight binary digits. A set of eight binary digits is also referred to as an octet. If you carry this one step further, you can see that this set of octets has 32 positions, which is why IP addresses are referred to as 32-bit numbers.
To see how you go about using the Route Utility as an interface to the Route command-line tool, let’s look at an example. Suppose that you want to add a route to the destination 10.41.0.0 with a subnet mask of 255.255.0.0, a gateway address of 10.27.0.1, and a metric of 7. If so, you would fill in the Route Utility’s dialog box as shown in Figure C.
Figure C
Filling in the Route Utility’s dialog box is much easier than typing on the DOS-based command line.
Once you fill in the dialog box, just click OK. When you do, you’ll see what basically amounts to a confirmation dialog box, which shows you the exact command line you’ve configured via the Route Utility and asks whether you want to execute it, as shown in Figure D.
Figure D
The Route Utility shows you the Route command line you’ve configured and prompts you to execute it.
If the command isn’t exactly what you wanted, click Cancel and you’ll be returned to the main Route Utility dialog box. There, you’ll see that everything is as you left it, and you can modify your Route command line without having to start from scratch. Of course, you can remove any parameter by clearing the check box or add a parameter by selecting a check box.
When you click OK, the Command Prompt window will appear on top of the Route Utility dialog box, and you’ll see the results of your Route command. When you close the Command Prompt window, you’ll once again see the Route Utility dialog box. This makes it easy to check your entry, should the results not be what you expected, and it makes it easy to take a look at the modified routing table via the Print command. You can also continue to tweak the routing table. When you’re finished, just click the Close button.
Getting quick help
If you need more details on any one of the Route command’s parameters, just click OK in the Route Utility dialog box without selecting any check boxes. When you see the confirmation dialog box, it will contain only the Route command. Just click OK, and the Command Prompt window will open and display the command-line help for the Route command.
In addition, you can find a more detailed explanation of the Route command’s parameters on Microsoft’s Windows XP Professional Product Documentation page.