Share via


Route

Other versions of this page are also available for the following:

Windows Mobile Not SupportedWindows Embedded CE Supported

8/28/2008

The route utility allows you to view or modify network routing tables.

The syntax for the route utility is as follows.

ROUTE [-d] [-f] command [destination] [MASK netmask] [gateway] 
[METRIC metric] [IF interface]

You can use the following options and parameters with the route utility:

  • -d
    Redirects the output to the output debug port.
  • -f
    Clears the routing tables of all gateway entries. If you use -f together with one of the commands, the tables are cleared before the command runs.
  • command
    Specifies a command that you want to run. It is one of the following values.

    Command Description

    ADD

    Adds a route.

    DELETE

    Deletes a route.

    PRINT

    Prints a route.

  • destination
    Specifies the address of the host.
  • MASK
    Specifies that the next parameter is the netmask value.
  • netmask
    Specifies a subnet mask value for this route entry. If you do not specify a value, the subnet mask is set to 255.255.255.255 by default.
  • gateway
    Specifies the address of the gateway.
  • METRIC
    Specifies that the next parameter is the metric value.
  • metric
    Specifies the metric, or cost, for the destination.
  • IF
    Specifies that the next parameter is the interface value. If you do not use the IF option, route tries to find the best interface for a given gateway.
  • interface
    Specifies the interface number for the route.

If you specify an invalid value for netmask, so that the result of a bitwise-AND operation between destination and netmask does not equal the value of destination, an error occurs. For example, if you use the following call for the route utility.

route ADD 157.0.0.0 MASK 155.0.0.0 157.55.80.1 IF 1

You receive the following error message.

The route addition failed: 87

The following code examples show several ways of calling the route utility.

route PRINT
route ADD 157.0.0.0 MASK 255.0.0.0  157.55.80.1 METRIC 3 IF 2
route DELETE 157.0.0.0

The following code example shows typical output from the route utility.

=============================================================================
 Interface List 
 2   0 40 5 5b 8b 9e    Novell 2000 Adapter.
=============================================================================

=============================================================================
 Active Routes 
  
 The no. of entries is ::: 7
      Destination       Netmask       GatewayAddress     Interface    Metric  
 ----------------------------------------------------------------------------
        224.0.0.0        224.0.0.0   157.56.148.199   157.56.148.199       1
          0.0.0.0          0.0.0.0     157.56.148.1   157.56.148.199       1
   157.56.148.199  255.255.255.255        127.0.0.1        127.0.0.1       1
   157.56.255.255  255.255.255.255   157.56.148.199   157.56.148.199       1
     157.56.148.0    255.255.252.0   157.56.148.199   157.56.148.199       1
  255.255.255.255  255.255.255.255   157.56.148.199   157.56.148.199       1
        127.0.0.0        255.0.0.0        127.0.0.1        127.0.0.1       1
=============================================================================

See Also

Other Resources

Network Utilities Application Development