route


route

Displays and modifies the routing table on the local machine.

Syntax

 route [-f] [-p] [   command   [   destination   ] [MASK   netmask   ] [   gateway   ]  [METRIC   metric   ] [IF   interface   ] 

Options

-f

Flushes all routes (gateway entries) from the routing table. (If combined with other options, this causes the table to be flushed prior to executing the other options.)

-p

When used with the add command, causes the added route to be persistent across reboots; when used with the print command, lists only persistent routes.

Commands

print

Displays the contents of the routing table.

add destination MASK netmask gateway METRIC metric IF interface

Adds a new route to the routing table using the following parameters:

destination

The IP address of the host or network, which can be reached by using the gateway.

netmask

The subnet mask used for packets going to the previously mentioned destination.

gateway

The IP address of the router interface used for routing packets to the previously mentioned destination.

metric

The cost metric, usually the number of hops between the local machine and destination, or any arbitrary number to represent the degree of preference of this route when many routes to destination are possible. (The default is 1, and maximum is 9,999.)

interface

The interface to add the route to on multihomed machines.

delete [destination MASK netmask gateway METRIC metric IF interface]

Removes an entry from the routing table. (Specify enough parameters to make the result unique.)

change [destination MASK netmask gateway METRIC metric IF interface]

Modifies an existing route in the routing table. (Specify enough parameters to make the result unique.)

Examples

Display the routing table on the local machine:

  route print  = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Interface List 0x1 ........................... MS TCP Loopback interface 0x1000003 ...00 40 95 d1 29 6c ...... Novell 2000 Adapter. = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Active Routes: Destination     Netmask          Gateway         Interface         Metric 0.0.0.0         0.0.0.0          172.16.11.1     172.16.11.100     1 127.0.0.0       255.0.0.0        127.0.0.1       127.0.0.1         1 172.16.11.0     255.255.255.0    172.16.11.100   172.16.11.100     1 172.16.11.100   255.255.255.255  127.0.0.1       127.0.0.1         1 172.16.255.255  255.255.255.255  172.16.11.100   172.16.11.100     1 224.0.0.0       224.0.0.0        172.16.11.100   172.16.11.100     1 255.255.255.255 255.255.255.255  172.16.11.100   172.16.11.100     1 Default Gateway:       172.16.11.1 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Persistent Routes:   None 

Add a persistent route to the class B network 133.16.0.0, which is accessible through the local router interface 172.16.11.2:

  route -p add 133.16.0.0 MASK 255.255.0.0 172.16.11.2 METRIC 3  

Verify the result:

  route print  = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Interface List 0x1 ........................... MS TCP Loopback interface 0x1000003 ...00 40 95 d1 29 6c ...... Novell 2000 Adapter. = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Active Routes: Destination     Netmask          Gateway         Interface         Metric 0.0.0.0         0.0.0.0          172.16.11.1     172.16.11.100     1 127.0.0.0       255.0.0.0        127.0.0.1       127.0.0.1         1 133.16.0.0      255.255.0.0      172.16.11.2     172.16.11.100     3 172.16.11.0     255.255.255.0    172.16.11.100   172.16.11.100     1 172.16.11.100   255.255.255.255  127.0.0.1       127.0.0.1         1 172.16.255.255  255.255.255.255  172.16.11.100   172.16.11.100     1 224.0.0.0       224.0.0.0        172.16.11.100   172.16.11.100     1 255.255.255.255 255.255.255.255  172.16.11.100   172.16.11.100     1 Default Gateway:       172.16.11.1 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Persistent Routes: Network Address  Netmask         Gateway Address  Metric 133.16.0.0       255.255.0.0     172.16.11.2      3 

Notes

  • If you use route -f indiscriminately on a server, you could interrupt network communications between the server and other computers on the network, causing users to lose work. However, rebooting the server restores the default gateways defined in Network in the Control Panel.

  • You can use the symbolic names contained in the Hosts and Networks files instead of IP addresses for destination or gateway parameters in the route command.

  • The delete and print commands support wildcards for the destination and gateway parameters.

  • The change command is useless; it's easier to delete a route and then add the new one than to modify an existing one.

See Also

TCP/IP



Windows Server 2003 in a Nutshell
Windows Server 2003 in a Nutshell
ISBN: 0596004044
EAN: 2147483647
Year: 2003
Pages: 415
Authors: Mitch Tulloch

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net