The route command is a program used to manually manipulate the
network routing tables. It normally is not needed, as a system
routing table management daemon, such as gated or routed, should
tend to this task.
The route command accepts these commands:
add Adds a route.
flush Removes all gateway entries from the routing tables. For
the inet6 family, it also removes all cloned routes. You
can choose to flush only those routes whose destinations
are of a given address family by specifying an optional
keyword (family) that specifies the address family.
delete Deletes a specific route.
change Changes aspects of a route (such as its gateway).
Unless the -net or -host parameters are specified on the
command line, route creates a host route or a network route by
interpreting the Internet address associated with destination
parameter. If the destination has a local address part of INADDR_
ANY, or if the destination is the symbolic name of a network, a
network route is created; otherwise, a host route is created.
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.
All symbolic names specified for a destination or gateway are
looked up first as a hostname using gethostbyname(3). If this
lookup fails, getnet-byname(3) is then used to interpret the name
as that of a network.
Routes added with the route command are marked as RTF_STATIC
to differentiate them from routes added by the routing daemons
(gated or routed). The gated daemon does not remove the RTF_
STATIC routes when it is shut down.
The route command uses a routing socket and the new message types
RTM_ADD, RTM_DELETE, and RTM_CHANGE. As such, only a privileged
user may modify the routing tables.