The best or maybe the fastest way to manage the Windows routing tables is using the command line. The key command is route, with the following syntax:

route [-f][-p] [-4|-6] command [destination] [mask *netmask*] [gateway] [metric *metric*] [if *interface*]
  • -f Clean routing tables in all the gateways.
  • -p When used with add, makes the route persistent between reboots. Not valid with Windows 95.
  • -4 Forces IPv4 use.
  • -6 Forces IPv6 use.
  • command It can be one of the following: print Prints a route. add Adds a route. delete removes a route. change Alters an existent route.
  • destination Specifies the destination.
  • mask Specifies that the next parameter in the line will be the netmask. If it is not there, will be /32 by default.
  • gateway Specifies the gateway.
  • interface Specifies interface number and specified route.
  • metric Specifies metric. Destination cost.

Every symbolic name used for destinations are searched on networks file. Those for the gateways are searched in hosts file.

If we use print or delete commands, both the gateway and the destination can be the star, *****, wildcard. We can also omit the gateway.

Examples

Show the routing table:

route print

Add a network route:

route add 192.168.10.0 mask 255.255.255.0 172.31.21.15

Remove a network route:

route delete 192.168.10.0 mask 255.255.255.0

Tricks

If we have two hosts within the same broadcast domain, using different network ranges’ IP addresses, we can still make them communicate with each other.

Let’s say, host A with address 192.168.10.111/24 and host B with address 192.168.30.200/24. Despite being from different networks, we can make them speak by issuing:

route add 192.168.30.200 mask 255.255.255.255 192.168.10.111