Table of Contents
route [ -fn ] add [ inet ] default gateway metric
route [ -fn ] delete [ inet ] [ host|net ] destination
route [ -fn ] delete [ inet ] default
route [ -fn ] add inet6 [ prefixlen prefixlen ] [ host|net ] destination gateway metric
route [ -fn ] add inet6 default gateway metric
route [ -fn ] delete inet6 [ prefixlen prefixlen ] [ host|net ] destination
route [ -fn ] delete inet6 default
route -s [ inet|inet6 ]
The optional inet keyword specifies the inet (Internet protocol version 4) address family routing table and causes route to expect addresses in that format for the rest of the command. The inet6 keyword specifies the inet6 (Internet protocol version 6) address family routing table and causes route to expect addresses in that format for the rest of the command. inet6 keyword is valid only if IPv6 is enabled on the node. If neither is specified, inet is assumed.
The add command adds the specified route for the given destination to the routing table. The delete command deletes the specified route from the routing table.
Routes to a particular host are distinguished from those to a network by interpreting the Internet address associated with destination. The optional keywords net and host force the destination to be interpreted as a network or a host, respectively. Otherwise, if the destination has a "local address part" of INADDR_ANY (for example, 0), or if the destination is the symbolic name of a network, then the route is assumed to be to a network; otherwise, it is presumed to be a route to a host. If the route is to a destination via a gateway, the metric parameter should be greater than 0. If metric is set to 0, the gateway given is the address of this host on the common network, indicating the interface to be used for transmission.
All symbolic names specified for a destination or gateway are looked up first as a host name in the /etc/hosts database. If this lookup fails, then the name is looked up as a network name in the /etc/networks database. "default" is also a valid destination, which is used if there is no specific host or network route.
For the inet address family the netmask for a route to a network is implicitly derived from the class of the network; to override that, the destination for a network route can have /bits or &mask after it, where bits is the number of high-order bits to be set in the netmask, or mask is the netmask (either as a number - defaults to decimal, precede with 0x for hexadecimal, precede with 0 for octal - or as an IP address, for example, 255.255.0.0). Thus the network 128.42.x.x may be specified by 126.96.36.199/16, 188.8.131.52&0xffff0000, 184.108.40.206&255.255.0.0, 220.127.116.11&037777600000, or 18.104.22.168&4294901760. For the inet6 address family use the prefixlen keyword and argument to specify the network mask.
Description of flags in the ouput
Count of lookups for this route.
add|delete [ host|net ] destination: gateway gateway: Confirmation of an add or delete command. May be followed by an error message if the command failed to complete successfully.
An attempt to add a route failed because the gateway listed was not on a directly-connected network. The next-hop gateway must be given.
not in table
A delete operation was attempted for an entry which wasn't present in the table.
entry already exists
An add operation was attempted for an existing route entry.
routing table overflow
An add operation was attempted, but the system was unable to allocate memory to create the new entry.
destination gateway done
When the -f flag is specified, each routing table entry deleted is indicated with a message of this form.
Table of Contents