ROUTE(8)

NAME
route - show / manipulate the IP routing table

SYNOPSIS
route [ -vn ]

route [ -v ] add [ -net | -host ] XXXX [gw GGGG] [metric MMMM] [netmask NNNN] [dev DDDD]

route [ -v ] del XXXX

DESCRIPTION
Route manipulates the kernel's IP routing table. Its primary use is to set up static routes to specific hosts or networks via an interface after it has been configured with the ifconfig(8) program. This version of route is intended solely for use with kernel versions 0.99pl14n and newer kernels.

OPTIONS

(none)
    prints out the kernel routing table, listing destination address, gateway, netmask for route ("Genmask"), flags (U = Up, H = Host, G = Gateway, D = dynamic, M = Modified), Metric (currently not supported), Ref, Use and Iface (i.e. which device the route maps to).

-n  same as previous, but shows numerical addresses instead of trying to determine symbolic host names.

-v  is a flag for verbose (not actually used).

del XXXX
    deletes the route associated with the destination address XXXX.

add [ -net | -host ] XXXX [gw GGGG] [metric MMMM] [netmask NNNN] [dev DDDD]
    adds a route to the IP address XXXX. The route is a network route if (a) the -net modifier is used or (b) XXXX is found in /etc/networks by the getnetbyname() library function and no -host modifier is used. The gw GGGG argument means that any IP packets sent to this address will be routed through the specified gateway. NOTE: The specified gateway must be reachable first. This usually means that you have to set up a static route to the gateway beforehand. The metric MMMM modifier is not yet implemented (and with the -v option will actually print a warning). The netmask NNNN modifier specifies the netmask of the route to be added. This only makes sense for a network route, and when the address XXXX actually makes sense with the specified netmask. If no netmask is given, route guesses it instead, so for most normal setups you won't need to specify a netmask. The dev DDDD modifier forces the route to be associated with the specified device, as the kernel will otherwise try to determine the device on its own (by checking already existing routes and device specifications, and where the route is added to). In most normal networks you won't need this. If dev DDDD is the last option on the command line, the word dev may be omitted, as it's the default. Otherwise the order of the route modifiers (metric - netmask - gw - dev) doesn't matter.

EXAMPLES

route add -net 127.0.0.0
    adds the normal loopback entry, using netmask 255.0.0.0 (Class A net, determined from the destination address) and associated with the lo device (assuming this device was prviously set up correctly with ifconfig(8) ).

route add -net 192.56.76.0 netmask 255.255.255.0 dev eth0
    adds a route to the network 192.56.76.x via eth0. The Class C netmask modifier is not really necessary here because 192.* is a Class C IP address. The word dev can be omitted here.

route add default gw mango-gw
    adds a default route (which will be used if no other route matches). All packets using this route will be gatewayed through "mango-gw". The device which will actually be used for that route depends on how we can reach "mango-gw" - the static route to "mango-gw" will have to be set up before.

route add ipx4 sl0

route add -net 192.57.66.0 netmask 255.255.255.0 gw ipx4
    This command sequence adds the route to the "ipx4" host via the SLIP interface (assuming that "ipx4" is the SLIP host), and then adds the net 192.57.66.0 to be gatewayed through that host.

FILES
/proc/net/route
/etc/networks
/etc/hosts

SEE ALSO
ifconfig(8)

HISTORY
Route for Linux was originally written by Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> and then modified by Johannes Stille and Linus Torvalds for pl15.