Linux Commands - Network Commands



Purpose of route


route provides a command that enables the user to manipulate the routes to and from the computer.


route Syntax


route options

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.





route Options


-net target is a network

-host target is a single host

-C display kernel routing cache

netmask specify the mask to add

gw gateway

default this is the location of the default gateway


route Output


Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface * U 0 0 0 eth0

link-local * U 0 0 0 eth0

loopback * U 0 0 0 lo

default UG 0 0 0 eth0



This shows output of route with no options. Notice the default gateway is 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 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.