Networking / Beginners

Using the route Command

Using the route command displays or modifies the computer's routing table. For a typical computer that has a single network interface and is connected to a local area network (LAN) that has a router, the routing table is pretty simple and isn't often the source of network problems. Still, if you're having trouble accessing other computers or other networks, you can use the route command to make sure that a bad entry in the computer's routing table isn't the culprit.

For a computer with more than one interface and that's configured to work as a router, the routing table is often a major source of trouble. Setting up the routing table properly is a key part of configuring a router to work.

Displaying the routing table

To display the routing table (both IPv4 and IPv6) in Windows, use the route print command. In Unix/Linux, you can just use route without any command line switches. The output displayed by the Windows and Unix/Linux commands are similar. Here's an example from a typical Windows client computer:

C:\>route print
Interface List
 8 ...00 12 3f a7 17 ba ...... Intel(R) PRO/100 VE Network Connection
 1 ........................... Software Loopback Interface 1
 9 ...02 00 54 55 4e 01 ...... Teredo Tunneling Pseudo-Interface
10 ...00 00 00 00 00 00 00 e0 isatap.{D0F85930-01E2-402F-B0FC-
IPv4 Route Table
Active Routes:
Network  	 Netmask 	Gateway       Interface     Metric
Destination   276 	 On-link       306 On-link       306 On-link       306 	 On-link   276 On-link   276 On-link   276 	 On-link       306 	 On-link   276 On-link 306 On-link   276
Persistent Routes:
Network Address     Netmask 	Gateway Address   Metric 	  Default
IPv6 Route Table
Active Routes:
If Metric Network Destination 	Gateway
9 	18 ::/0 		On-link
1	306 ::1/128 		On-link
9 	18 2001::/32 		On-link
9 	266 2001:0:4136:e38c:2c6c:670:3f57:fe91/128
8 	276 fe80::/64 		On-link
9 	266 fe80::/64 		On-link
10 	281 fe80::5efe:
8 	276 fe80::cca:9067:9427:a911/128
9 	266 fe80::2c6c:670:3f57:fe91/128
1 	306 ff00::/8 		On-link
9 	266 ff00::/8 		On-link
8 	276 ff00::/8 		On-link
Persistent Routes:

For each entry in the routing table, five items of information are listed:

  • The destination IP address Actually, this is the address of the destination subnet, and must be interpreted in the context of the subnet mask.
  • The subnet mask that must be applied to the destination address to determine the destination subnet
  • The IP address of the gateway to which traffic intended for the destination subnet will be sent
  • The IP address of the interface through which the traffic will be sent to the destination subnet
  • The metric, which indicates the number of hops required to reach destinations via the gateway

Each packet that's processed by the computer is evaluated against the rules in the routing table. If the packet's destination address matches the destination subnet for the rule, the packet is sent to the specified gateway via the specified network interface. If not, the next rule is applied.

The computer on which I ran the route command in this example is on a private subnet. The computer's IP address is, and the default gateway is a router at

Here's how the rules shown in this example are used. Notice that you have to read the entries from the bottom up:

  • The first rule is for packets sent to, with subnet mask This special IP address is for broadcast packets. The rule specifies that these broadcast packets should be delivered to the local network interface (
  • The next rule is for packets sent to, again with subnet mask These are also broadcast packets and are sent to the local network interface.
  • The next rule is for packets sent to, again with subnet mask This is for packets that the computer is sending to itself via its own IP address. This rule specifies that these packets will be sent to the local loopback interface on
  • The next rule is for packets sent to, with subnet mask These are packets intended for the local subnet. They're sent to the subnet via the local interface at
  • The next rule is for packets sent to the loopback address (, subnet mask These packets are sent straight through to the loopback interface,
  • The last rule is for everything else. All IP addresses will match the destination IP address with subnet mask and will be sent to the default gateway router at via the computer's network interface at
Tip: One major difference between the Windows version of route and the Unix/ Linux version is the order in which they list the routing table. The Windows route command lists the table starting with the most general entry and works toward the most specific. The Unix/Linux version is the other way around: It starts with the most specific and works toward the more general. The Unix/Linux order makes more sense - the Windows route command displays the routing list upside down.

Modifying the routing table

Besides displaying the routing table, the route command also lets you modify it by adding, deleting, or changing entries.

Warning You shouldn't do this unless you know what you're doing. If you mess up the routing table, your computer may not be able to communicate with anyone.

The syntax for the route command for adding, deleting, or changing a route entry is

route [-p] command dest [mask subnet] gateway [-if interface]

The following list describes each of the route command's parameters:

  • -p: Makes the entry persistent. If you omit -p, the entry will be deleted the next time you reboot. (Use this only with add commands.)
  • command: Add, delete, or change.
  • dest: The IP address of the destination subnet.
  • mask subnet: The subnet mask. If you omit the subnet mask, the default is, meaning that the entry will apply only to a single host rather than a subnet. You usually want to include the mask.
  • gateway: The IP address of the gateway to which packets will be sent.
  • -if interface: The IP address of the interface through which packets will be sent. If your computer has only one network interface, you can omit this.

Suppose that your network has a second router that serves as a link to another private subnet, (subnet mask The interface on the local side of this router is at To add a static route entry that sends packets intended for the subnet to this router, use a command like this:

C:\>route -p add mask

Now, suppose that you later change the IP address of the router to You can update this route with the following command:

C:\>route change mask

If you omit the mask from a route change command, the command changes the mask to!

Finally, suppose that you realize that setting up a second router on this network wasn't such a good idea after all, so you want to just delete the entry. The following command will do the trick:

C:\>route delete
[Previous] [Contents] [Next]