route |
Displays and modifies the routing table on the local machine.
route [-f] [-p] [ command [ destination ] [MASK netmask ] [ gateway ] [METRIC metric ] [IF interface ]
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.)
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.
Displays the contents of the routing table.
Adds a new route to the routing table using the following parameters:
The IP address of the host or network, which can be reached by using the gateway.
The subnet mask used for packets going to the previously mentioned destination.
The IP address of the router interface used for routing packets to the previously mentioned destination.
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.)
The interface to add the route to on multihomed machines.
Removes an entry from the routing table. (Specify enough parameters to make the result unique.)
Modifies an existing route in the routing table. (Specify enough parameters to make the result unique.)
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
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.
TCP/IP