ROUTE(8C) Domain/OS BSD ROUTE(8C)
NAME
route - manually manipulate the routing tables
SYNOPSIS
/etc/route [-f] [-n] [command args]
DESCRIPTION
route is a program used to manually manipulate the network routing
tables. It normally is not needed, as the system routing table
management daemon, routed(8C), should tend to this task.
route accepts three commands: add, to add a route; addp, to add a
priority route; and delete, to delete a route.
The addp command adds a priority route. The TCP/IP server process will
use priority routes before default routes or routes established by
routed(8C). A route added with addp will appear first in the gateway
table (displayed with the BSD command netstat -r(1)). You can only add
priority routes with addp. Routes added manually by route cannot be
deleted by routed(8C).
COMMAND SYNTAX
All commands have the following syntax:
/etc/route command [ net | host ] destination gateway [ metric ]
where destination is the destination host or network, gateway is the
next-hop gateway to which packets should be addressed, and metric is a
count indicating the number of hops to the destination. The metric is
required for add and addp commands; it must be greater than zero if the
destination is on a directly-attached network or if the route utilizes
one or more gateways. (See the Notes section below for important
information about adding routes to gateways on directly-attached
networks.)
The route command does not support subnet addresses as part of symbolic
or numeric destination network names. A destination network address that
includes a subnet portion will be misinterpreted, resulting in an
incorrect address.
Any symbolic name specified for destination or gateway is looked up first
as a net name by getnetbyname(3N). If this lookup fails,
gethostbyname(3N) then interprets the name as a host name.
For numeric names, routes to a particular host are distinguished from
those to a network by interpreting the Internet address associated with
destination. The optional keywords net (default) and host force
destination to be interpreted in network or host format, respectively.
When the optional keyword net is not specified, a numeric destination
address takes the complete Internet address format specified in inet(3N).
A destination specified in this way can be either a host or network,
depending on whether the "local address part" is INADDR_ANY.
When the optional keyword net is specified, a numeric destination name is
interpreted as giving only the network portion of the Internet address.
Any subnet or host portion in the numeric destination network name will
be misinterpreted and result in an incorrect address. A "local address
part" of INADDR_ANY is then appended to the given network address to form
the complete Internet address of the destination network.
For example, 128.32 or host 128.32 is interpreted as 128.0.0.32;
128.32.130 or host 128.32.130 is interpreted as 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.
You can add a default route as follows:
/etc/route add default gateway_name [non-zero metric]
TCP/IP software will use the default route when other routes occuring
earlier in the routing table have failed, or when there are no other
possible routes.
route uses a raw socket and the SIOCADDRT and SIOCDELRT ioctl's(2) to do
its work. As such, only the super-user may modify the routing tables.
OPTIONS
-f "Flush" the routing tables of all gateway entries. Using this
option in conjunction with one of the commands described above
flushes the tables prior to the command's application. Note that
if you start routed prior to using the route -f command, routed is
not aware that tcpd's routing tables have been flushed.
Therefore, routed does not automatically tell tcpd about all of
its routes. For this reason, we recommend that you do not use the
route -f command when you are also running routed, unless you
restart routed after the route -f command successfully completes.
When you restart routed, as part of its initialization, it tells
tcpd about all of its known routes.
-n Suppress printing symbolic host and network names when reporting
actions.
DIAGNOSTICS
add [ host | 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(3N)), the
gateway address is printed numerically as well as symbolically.
delete [ host | network ] %s: gateway %s flags %x
As above, but when deleting an entry.
%s %s done
When the -f flag 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 that 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.
NOTES
If you attempt to use metric 0 to add a regular or priority route to a
gateway on a directly-connected network, the metric is automatically
incremented to 1 and the connection fails. This occurs because we do not
support configurations with multiple logical networks on a single
physical network. All nodes on the same physical network must have the
same network address. If your network is subnetted, all nodes must also
have the same subnet number.
SEE ALSO
intro(4N), routed(8C);
Configuring and Managing TCP/IP.