Linux version

route - 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.
For hosts 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 select verbose operation.
-A family address family (eg inet inet6, ax25, netrom ipx,ddp x25
 
add default add the default route
add target the destination network or host IP addresses in dotted decimal or host/network names.
del target delete a route.
 
-net the target is a network.
-host the 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 the nnn.nnn.nnn.sss as a hexadecimal mask.
a common value is FF.FF.FF.00. (specified as 255.255.255.0 ) 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.
for examples:
source192.168.23.28192.168.23.28192.168.24.27
source cannot contact gateway
gateway 192.168.23.1192.168.23.1192.168.23.1
netmask255.255.255.0
x'FF.FF.FF.00'
leftmost 3 portions of the address are used to determine if destination is withing the subnet
255.255.254.0
x'FF.FF.FE.00
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
255.255.255.0
destination
192.168.23.83
within subnet within subnet
destination
192.168.24.28
not within subnet
packets send to gateway in order to reach another subnet.
within subnet
both gateway and destination in 1-126 range
192.168.24.143outside 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.
-e
-ee
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

EXAMPLES

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

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.

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

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

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

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

OUTPUT

Destination The destination network or destination host.
Gateway The gateway address or '*' if none set.
Genmask The netmask for the destination net;
'255.255.255.255' for a host destination and
'0.0.0.0' for the default route.
Flags
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
192.168.1.0     *               255.255.255.0   U     0      0        0 eth0
loopback        *               255.0.0.0       U     0      0        0 lo
default         Wireless_Broadb 0.0.0.0         UG    0      0        0 eth0

FILES

/proc/net/ipv6_route
/proc/net/route
/proc/net/rt_cache
SEE ALSO ifconfig, netstat, arp, rarp

net-tools
January 2000

BSD version