Network Administration: Modifying the Routing Table - dummies

Network Administration: Modifying the Routing Table

You can use the route command to display or modify the computer’s routing table. 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. Besides displaying the routing table, the route command also lets you modify it by adding, deleting, or changing entries.

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 255.255.255.255, 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, 192.168.2.0 (subnet mask 255.255.255.0). The interface on the local side of this router is at 192.168.1.200. To add a static route entry that sends packets intended for the 192.168.2.0 subnet to this router, use a command like this:

C:>route -p add 192.168.2.0 mask 255.255.255.0 192.168.1.200

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

C:>route change 192.168.2.0 mask 255.255.255.0 192.168.1.222

Notice that the mask is specified again. If you omit the mask from a route change command, the command changes the mask to 255.255.255.255!

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 192.168.2.0