TCP/IP Troubleshooting

Previous Topic Next Topic

Route

Route is used to view and modify the IP routing table. Route Print displays a list of current routes that the host knows. Sample output from the route command is shown in "Troubleshooting IP Routing" later in this chapter. Route Add adds routes to the table. Route Delete removes routes from the host's routing table.


note-icon

Note

Routes added to a routing table are not made persistent unless the -p switch is specified. Non-persistent routes only last until the computer is restarted or until the interface is deactivated. The interface can be deactivated when the plug-and-play interface is unplugged (such as for laptops and hot-swap PCs), when the wire is removed from the media card (if the adapter supports media fault sensing), or when the interface is manually disconnected from the adapter in the Network and Dial-up Connections folder.

For two hosts to exchange IP datagrams, they must both have a route to each other, or they must use a default gateway that knows a route between the two. Normally, routers exchange information using a protocol such as Routing Information Protocol (RIP) or Open Shortest Path First (OSPF). RIP Listening service is available for Microsoft® Windows® 2000 Professional, and full routing protocols are supported by Windows 2000 Server in the Routing and Remote Access service.

The usage for Route is route [-f] [-p] [command [destination]] [MASK netmask] [gateway] [metric metric] [if interface].

The commands usable in the syntax above are Print, Add, Delete, and Change. Table 3.11 lists these commands as well as the other Route switches and parameters.

Table 3.11 Route Switches

Switch Function
-f Clears the routing table of all gateway entries. If this is used in conjunction with one of the other commands, the tables are cleared prior to running the command.
-p When used with the Add command, this switch adds the route to the routing table and to the Windows 2000 registry. The route is automatically added to the routing table each time the TCP/IP protocol is initialized. By default, routes added without the -p switch are only stored in the RAM-based IP routing table and are not preserved when the TCP/IP is restarted. This option is ignored for all other commands.
Print <destination> Prints a route to the specified host. Optionally, prints the routes for the specified destination.
Add <destination> Mask <netmask> <gateway> Metric <metric> if <interface> Adds a route for the specified destination using the forwarding IP address of the gateway. The metric and if options are not required.
Delete <destination> Deletes a route for the specified destination.
Change <destination> Mask <netmask> <gateway> Metric <metric> if <interface> Modifies an existing route.
Mask <netmask> Specifies that the next parameter is the network mask value. If a netmask value is not specified, it defaults to 255.255.255.255.
Metric <metric> Specifies the cost to reach the destination. Routes with lower metrics are chosen over routes with higher metrics. A typical use of the metric value is to indicate the number of routers that must be crossed to reach the destination.
if <interface> Specifies the IP address of the interface over which the destination is available.

All symbolic names used for the destination are looked up in the network database file NETWORKS. The symbolic names for the gateway are looked up in the host name database file HOSTS. If the command is print or delete, the destination value can be a wildcard value specified by an asterisk ("*"). If the destination specified contains a * or ?, it is treated as a shell pattern, and only matching destination routes are printed. The asterisk matches any string, and the question mark matches any one character. For example, 157.*.1, 157.*, 127.*, *224* are all valid uses of the wildcard asterisk.

Using an invalid combination of a destination and netmask value generates a "route: bad gateway address netmask" error. This sort of error message appears, for example, when a bitwise logical AND between the destination and mask does not equal the destination value.

© 1985-2000 Microsoft Corporation. All rights reserved.