Linux version


show / manipulate the IP routing table

route [-CFvnee]

route [-v] [-A family] add [-net|-host] target|default [netmask Nm] [gw Gw] [metric N]
                                                    [mss M] [window W] [irtt I] [reject]
                                                    [mod] [dyn] [reinstate]
                                                    [[dev] If]

route [-v] [-A family] del [-net|-host] target|default [netmask Nm] [gw Gw] [metric N]
                                                    [[dev] If]

route [-V| --version] [-h| --help]

Display, add or delete entries in the kernel's IP routing tables.
With multiple interfaces, specifies which interface to use when sending packets based on destination network address.

add or del options modify the routing tables.

-v verbose .
-A family address family (eg inet inet6, ax25, netrom ipx,ddp x25
add default add the default route
add target destination network or host IP addresses in dotted decimal or host/network names.
del target delete a route.
-net target is a network.
-host target is a host.
gw ddd.ddd.ddd.ddd route packets via a gateway. The specified gateway must be reachable first. set up a static route to the gateway . If you specify the address of one of your local interfaces, it will be used to decide about the interface to which the packets should be routed to.
netmask nnn.nnn.nnn.sss defines portion of the address outside of this subnet.
Packets whose destination does not match the address of the gateway in the bits set in the netmask need to be forwarded to the gateway.
Consider nnn.nnn.nnn.sss as a hexadecimal mask.
a common value is FF.FF.FF.00. (specified as ) this means that all the bits in the first 3 portions of the address must match the gateway. The rightmost portion defines which host within this subnet is the destination.
source cannot contact gateway
Leftmost 3 portions of the address are used to determine if destination is withing the subnet
Leftmost 2 portions must match and values in the third position must both (gateway and destination ) be in a the matching range from 1-126 or 128-254
within subnet within subnet
not within subnet
packets send to gateway in order to reach another subnet.
within subnet
both gateway and destination in 1-126 range subnetoutside subnet
although leftmost 2 digits match , gateway is in 1-126 range but
destination is not
metric M set the metric field in the routing table (used by routing daemons) to M. Entries with higher metrics are avoided.
mss b set the TCP Maximum Segment Size (MSS) for connections over this route to b bytes. The default is the device MTU minus headers, or a lower MTU when path mtu discovery occured. This setting can be used to force smaller TCP packets on the other end when path mtu discovery does not work (usually because of misconfigured firewalls that block ICMP Fragmentation Needed)
window W set the TCP window size for connections over this route to w bytes. This is typically only used on AX.25 networks and with drivers unable to handle back to back frames.
irtt I set the initial round trip time (irtt) for TCP connections over this route to I milliseconds (1-12000). This is typically only used on AX.25 networks. default 300ms .
reject install a blocking route, which will force a route lookup to fail. mask out networks before using the default route.
mod, dyn, reinstate install a dynamic or modified route for diagnostic purposes, and are generally only set by routing daemons.
-F operate on the kernel's FIB (Forwarding Information Base) routing table. default.
-C operate on the kernel's routing cache.
dev If force the route to be associated with the specified device. (rarely used)
-n display numerical addresses instead of host names. Useful when the nameserver is inaccessable.
use netstat-format for displaying the routing table.
-ee includes metric, Ref, Use If dev If is the last option on the command line, dev is optional


route add default gw mango-gw
Packets to destinations not matching other gateways are sent to mango-gw.

route add -net netmask dev eth0
adds a route to the network 192.56.76.x via eth0.

route add oldstandby sl0
the "oldstandby" host uses the SLIP interface ( serial Link Interface Protocol , might be dialup modem)

route add -net netmask gw oldstandby
the net "192.57.66.x" is to be gatewayed through to the SLIP interface.

route add -net netmask dev eth0
sets all of the multicast IP routes to go via "eth0".(normal configuration line with a multicasting )

route add -net netmask reject
installs a rejecting route for the private network "10.x.x.x."


Destination The destination network or destination host.
Gateway The gateway address or '*' if none set.
Genmask The netmask for the destination net;
'' for a host destination and
'' for the default route.
U route is up
H target is a host
G use gateway
R reinstate route for dynamic routing
D dynamically installed by daemon or redirect
M modified from routing daemon or redirect
A installed by addrconf
C cache entry
! reject route
Metric* The 'distance' to the target in hops (router handoffs).
Ref* Number of references to this route.
Use* Count of lookups for the route. Depending on the use of -F and -C this will be either route cache misses (-F) or hits (-C).
Iface Interface to which packets for this route will be sent.
MSS Default maximum segement size for TCP connections over this route.
Window Default window size for TCP connections over this route.
irtt Initial RTT (Round Trip Time). The kernel uses this to guess about the best TCP protocol parameters without waiting on (possibly slow) answers.
HH (cached only) number of ARP entries and cached routes that refer to the hardware header cache for the cached route. This will be -1 if a hardware address is not needed for the interface of the cached route (e.g. lo).
Arp (cached only) Whether or not the hardware address for the cached route is up to date.
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface     *        U     0      0        0 eth0
loopback        *            U     0      0        0 lo
default         Wireless_Broadb         UG    0      0        0 eth0


SEE ALSO ifconfig, netstat, arp, rarp

January 2000

BSD version