The route utility supports a limited number of general options, but a rich command language, enabling the user to specify any arbitrary request that could be delivered via the programmatic interface discussed in route(4).
The following options are available:
|Specify inet address family as family hint for subcommands.
|Specify inet6 address family as family hint for subcommands.
|Run in debug-only mode, i.e., do not actually modify the routing table.
|Bypass attempts to print host and network names symbolically when reporting actions. (The process of translating between symbolic names and numerical equivalents can be quite time consuming, and may require correct operation of the network; thus it may be expedient to forget this, especially when attempting to repair networking operations).
|Run in test-only mode. /dev/null is used instead of a socket.
|(verbose) Print additional details.
|Suppress all output from the add, change, delete, and flush commands.
The route utility provides the following commands:
|Add a route.
|Remove all routes.
|Delete a specific route.
|Another name for the delete command.
|Change aspects of a route (such as its gateway).
|Lookup and display the route for a destination.
|Continuously report any changes to the routing information base, routing lookup misses, or suspected network partitionings.
|Another name for the get command.
The monitor command has the syntax:
The flush command has the syntax:
command is specified,
will ``flush'' the routing tables of all gateway entries.
When the address family may is specified by any of the
The add command has the following syntax:
and the other commands have the following syntax:
is the destination host or network,
is the next-hop intermediary via which packets should be routed.
Routes to a particular host may be distinguished from those to
a network by interpreting the Internet address specified as the
The optional modifiers
is interpreted as
is a synonym for the default route.
If the destination is directly reachable
via an interface requiring
no intermediary system to act as a gateway, the
The optional modifiers
Routes have associated flags which influence operation of the protocols when sending to destinations matched by the routes. These flags may be set (or sometimes cleared) by indicating the following corresponding modifiers:
-xresolve RTF_XRESOLVE - emit mesg on use (for external lookup) -iface ~RTF_GATEWAY - destination is directly reachable -static RTF_STATIC - manually added route -nostatic ~RTF_STATIC - pretend route added by kernel or daemon -reject RTF_REJECT - emit an ICMP unreachable when matched -blackhole RTF_BLACKHOLE - silently discard pkts (during updates) -proto1 RTF_PROTO1 - set protocol specific routing flag #1 -proto2 RTF_PROTO2 - set protocol specific routing flag #2
The optional modifiers
The optional modifier
allows multiple FIBs by a comma-separeted list and/or range
command where the destination and gateway are not sufficient to specify
the route (as in the
case where several interfaces may have the
same address), the
All symbolic names specified for a destination or gateway are looked up first as a host name using gethostbyname(3). If this lookup fails, getnetbyname(3) is then used to interpret the name as that of a network.
The route utility uses a routing socket and the new message types RTM_ADD, RTM_DELETE, RTM_GET, and RTM_CHANGE. As such, only the super-user may modify the routing tables.
route add -net 0.0.0.0/0 192.168.1.1
A shorter version of adding a default route can also be written as:
route add default 192.168.1.1
Add a static route to the 172.16.10.0/24 network via the 172.16.1.1 gateway:
route add -net 172.16.10.0/24 172.16.1.1
Change the gateway of an already established static route in the routing table:
route change -net 172.16.10.0/24 172.16.1.2
Display the route for a destination network:
route show 172.16.10.0
Delete a static route from the routing table:
route delete -net 172.16.10.0/24 172.16.1.2
Remove all routes from the routing table:
|add [host amp;| network ] %s: gateway %s flags %x
|The specified route is being added to the tables. The values printed are from the routing table entry supplied in the ioctl(2) call. If the gateway address used was not the primary address of the gateway (the first one returned by gethostbyname(3)), the gateway address is printed numerically as well as symbolically.
|delete [ host amp;| network ] %s: gateway %s flags %x
|As above, but when deleting an entry.
|%s %s done
|When the flush command is specified, each routing table entry deleted is indicated with a message of this form.
|Network is unreachable
|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 was not present in the tables.
|routing table overflow
|An add operation was attempted, but the system was low on resources and was unable to allocate memory to create the new entry.
|gateway uses the same route
|A change operation resulted in a route whose gateway uses the same route as the one being changed. The next-hop gateway should be reachable through a different route.
Currently, routes with the
flag set need to have the gateway set to an instance of the
driver, using the
|January 9, 2019
|The most horrifying thing about Unix is that, no matter how many times you hit yourself over the head with it, you never quite manage to lose consciousness. It just goes on and on.
|— Patrick Sobalvarro