- Linux Training
- Desktop Tutorials
- Server Tutorials
|Linux Commands - Network Commands|
Purpose of route
route provides a command that enables the user to manipulate the routes to and from the computer.
Without options the route command will display the current routing table.
route add options target
The route add command will add routes, gateways, etc. to the routing table.
route del options target
The route del command will remove routes, gateways, etc from the routing table.
-net target is a network
-host target is a single host
-C display kernel routing cache
netmask specify the mask to add
default this is the location of the default gateway
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.3.0 * 255.255.255.0 U 0 0 0 eth0
link-local * 255.255.0.0 U 0 0 0 eth0
loopback * 255.0.0.0 U 0 0 0 lo
default 192.168.3.1 0.0.0.0 UG 0 0 0 eth0
This shows output of route with no options. Notice the default gateway is 192.168.3.1 and there is only one network card, eth0. The U flag indicates that connection is up and the G flag is for gateway. The Metric is the number of hops to that target.
route add default gw
route add default gw 192.168.3.1 eth0
There is only one default gateway. This is typically the route that a computer must take to access the Internet. It is possible to add an additional gateway but it would not be the default.