A route is used to describe the gateway IP address and network interface to use when sending packets to a network. The routing table on a host computer contains a list of destination networks and the routes to those networks. This article describes adding entries to this routing table that will be deleted on reboot.
First we are going to add a route to the 192.168.10.1/24 network through the gateway of 10.10.0.1 to do this we would use the following command
Start->Run->CMD->Enter
route add 192.168.10.1 mask 255.255.255.0 10.10.0.1
This is the easiest way to add a temporary route. As a note the subnet mask is optional but if you don't specify one it is defaulted to 255.255.255.255. This says that the target is a single ip and not a subnet.
You can also add a routing metric to the route command. This could be refered to a a cost for the route. If a routing table contains multiple routes to the same destination, the cheapest route or lowest metric will be used.
To add a route with a metric of 10 to the host 192.168.10.2 through the gateway of 10.10.0.1 we would use the following command
Start->Run->CMD->Enter
route add 192.168.10.2 10.10.0.1 metric 10
Notice that we didn't specify a subnet mask so here we let it default to 255.255.255.255
If multiple nics are available to route to the same destination, the interface to use can be specified in the route command. The interface number associated with the interface is shown using the route print command. Windows will automatically pick which interface is the best for the given route. If you want to specify which interface to use , the if {interface} parameter can be used. To specify that the previous route example should use interface 2, this is identified with the hexadecimal value 0x2 from the route print command, use the following command:
Start->Run->CMD->Enter
route add 192.168.10.2 10.10.0.1 metric 10 if 2
No comments:
Post a Comment