The route command serves to set and manage routing information in a computer. The route command knows exactly two options; one to set, and one to delete, static routes. Dynamic routes are set by routing protocols.
-Afamily specifies the address family (inet, inet6, etc.).
-n shows addresses in dotted decimal notation and does not attempt to resolve them into DNS names.
-e specifies the routing table in netstat format.
-ee shows all information of the routing table.
-net means that the specified address denotes a (sub)network and not a computer.
-host shows that the address denotes a computer.
-F shows the Forwarding Information Base (routing table). The options -e and -ee can be used to specify a format for the output.
-C shows the current routing cache of the kernel.
del deletes the specified route.
add adds a route to the routing table.
address specifies the route destination. This can be a (sub)network or a computer. The address can be written in dotted decimal notation or as a DNS name.
netmaskmask is the network mask for the new route.
gwgateway specifies a gateway (router). All packets on this route are sent over this router, which knows the further path. Before it can be used as gateway for some destination, a computer has to know the route to it; either we must previously have set a static route, or the destination should be reachable over the default route.
metricmetric sets the metrics for this entry in the routing table.
mssMSS sets the maximum segment size of TCP to MSS bytes. The default value is 536 bytes.
devinterface specifies that packets on this route should always be output over the specified network device. If no device is specified, then the kernel attempts to find a network device to be used from other routes.
default denotes the default route for all routes that do not have a matching entry in the routing table.
The output of the route command corresponds largely to the output of netstat. (See Section C.3.)
Examples
root@tux # route add -net 127.0.0.0.
sets the entry for the loopback network device. Because no network mask was specified, the default network mask for a class-A network is assumed (255.0.0.0).
root@tux # route add -net 129.13.42.0 netmask 255.255.255.0 dev eth0
forwards the route for all addresses in network 129.13.42.0 to the network eth0. Packets are sent directly to the computers in network 129.13.42, not over a router.
sets the default route to router router-icsi. All packets that have no matching route in the routing table are sent over this gateway. In IP computers, a default gateway should always be specified, because no computer stores the routes to all computers in the Internet.