The route command
manually manipulates the network routing tables.
Options supported by
route:
-n
Prevents attempts to print host and network names symbolically
when reporting actions.
-q
Suppresses all output.
-v
Displays additional details (Verbose mode).
Commands accepted by
route:
add
Adds a route.
change
Changes aspects of a route (such as its gateway).
delete
Deletes a specific route.
flush
Removes all gateway entries from the routing tables.
get
Looks up and displays the route for a destination.
monitor
Continuously reports any changes to the routing information base,
routing lookup misses, or suspected network partionings.
Parameters accepted by route:
destination
Specifies the destination host or network. See the gateway
option for acceptable formats.
For those destinations that do not require a unique routing
table entry, use default as the destination
parameter. For example:
route add default gator
In this example, gator is the hostname of the machine
functioning as the gateway.
gateway
Specifies the next-hop gateway to which packets should be addressed.
The gateway and destination can be Internet addresses or names.
All symbolic names specified for a destination or
gateway are looked up first as a host name using
gethostbyname(SLIB).
If this lookup fails,
getnetbyname(SLIB)
is then used to interpret the name as that of a network.
Modifiers accepted by
route:
family
Flushes only those routes whose destinations are of the specified
address family. Currently, inet is the only supported address
family.
-host
Forces the destination to be interpreted as a host.
For more information on -net and -host,
see the paragraph following this list of options.
-interface
Specifies that the route uses an interface rather than a gateway.
The specified gateway is the address of this host on the common
network, indicating the interface to be used for transmission.
interface_spec
Specifies the interface name or interface address. This option is
needed only when the destination and gateway are not sufficient
to identify the route for add or change commands.
-ifa
Tells route to interpret the interface_spec option
as an interface address.
-ifp
Tells route to interpret the interface_spec option
as an interface name.
lock_mod
Locks the initial value provided by the metrics option.
Available lock meta-modifiers are -lock, which can be
used to lock metric options individually by preceding each metric to be
locked, or -lockrest, whick locks all ensuing metrics.
metrics
Provides initial values for metrics maintained in the routing
entry. Available metric options are:
-expire
Specify the expiry time of the route in seconds.
An expiry time of 0 implies that the route will not expire.
-hopcount
Specify the number of hops.
-mtu
Specify the maximum transmission unit in bytes.
-recvpipe
Specify the bandwidth of the receive pipe in bytes.
-rtt
Specify the round-trip time in milliseconds.
-rttvar
Specify the variance in round-trip time in milliseconds.
-sendpipe
Specify the bandwidth of the send pipe in bytes.
-ssthresh
Specify the slow start threshold size in bytes.
-tos
Specify the type of service as defined in RFC 1349.
The option should be followed by a number
specifying the desired value.
Note that most routing protocols only use or calculate
a subset of these metrics, and so route get
may display their values as 0.
For example, RIP uses the hop count metric.
These values may be locked by specifying a lock_mod.
-net
Forces the destination to be interpreted as a network.
For more information on -net and -host,
see the paragraph following this list of options.
-netmask
Overrides the implicit network mask with the one specified in
new_mask.
new_mask
Specifies the replacement network mask.
new_gateway
Specifies the new gateway.
If one of the optional keywords -host or -net does
not follow the command, routes to a particular host are
distinguished from those to a network by interpreting the
Internet address associated with destination. If
the destination has a ``local address
part'' of INADDR_ANY or if the
destination is the symbolic name of a network,
the route is assumed to be to a network; otherwise, it is
presumed to be a route to a host.
For example:
128.32 is interpreted as ``-host 128.0.0.32'';
128.32.130 is interpreted as ``-host 128.32.0.130'';
-net 128.32 is interpreted as ``128.32.0.0''; and
-net 128.32.130 is interpreted as ``128.32.130.0''.
route
uses a routing stream and the new message types
RTM_ADD,
RTM_DELETE,
RTM_GET,
and
RTM_CHANGE.
Therefore, only root may modify the routing
tables.
The kernel variables ipforwarding and
ipsendredirects are pertinent to systems
set up as routers. For details on these kernel variables, see
``Internet Protocol (IP) parameters'' in the Performance Guide.
Diagnostics
Error messages
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 wasn't
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.
Confirmation messages
add hostdestination:gatewaygatewayflagshex-flags
The specified route to a host is being added to the
tables. The values printed are from the routing table
entry supplied in the ioctl call. If the gateway
address used was not the primary address of the gateway
(i.e., the first one returned by gethostbyname),
the gateway address is printed numerically as well as
symbolically.