Manually manipulate the routing tables
route [-f] [-n] [-q] [-v] command { [[modifiers] args] }
You use the route utility to manually manipulate the network routing tables. Because the routing tables are usually taken care of by the routed daemon, you rarely need to use this utility.
The route utility accepts the following commands: add, change, delete, flush, get, monitor, and show.
Here's the syntax and the description for each command:
If the keyword, default, or the network address, 0.0.0.0,
is specified, then all packets sent to a remote network that's not
defined in the routing tables, are sent to the specified gateway.
If you have an Internet Service Provider (ISP), packets sent to hosts on the Internet are sent to a gateway provided by the ISP. See the defaultroute option in pppd. |
Routes to a particular host are distinguished from those to a network by interpreting the Internet address associated with destination. Specifying the optional keywords -net and -host force the destination to be interpreted as a network or a host, respectively.
If the destination has a "local address part" of INADDR_ANY, or if the destination is the symbolic name of a network, then the route is assumed to be to a network; otherwise, the route is assumed to be to a host. For example:
This destination: | Is interpreted as: |
---|---|
128.32 | -host 128.0.0.32 |
128.32.130 | -host 128.32.0.130 |
-net 128.32 | 128.32.0.0 |
-net 128.32.130 | 128.32.130.0. |
If the route is via an interface rather than via a gateway, you should specify the -interface modifier; the gateway given is the address of this host on the common network, indicating the interface to be used for transmission.
You can use the optional -netmask modifier to specify an additional address parameter that's interpreted as a network mask. You can use this like an OSI ESIS redirect with the netmask option, or to manually add subnet routes with netmasks different from that of the implied network interface (as would otherwise be communicated using the OSPF or ISIS routing protocols). After -netmask, enter the address parameter you want interpreted as the network mask.
You can override the implicit network mask generated in the INET case by placing this option after the destination parameter.
Similarly, you can use the -prefixlen modifier for IPv6.
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:
The optional modifiers:
provide initial values to metrics maintained in the routing entry. To lock any of these modifiers, precede the modifier with the -lock meta-modifier; you can also specify the -lockrest meta-modifier to lock all ensuing metrics.
All symbolic names specified for a destination or gateway are looked up first as a hostname using gethostname(). If this lookup fails, getnetbyname() 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, and RTM_CHANGE. As such, only the superuser may modify the routing tables.
This utility is based on copyright software of the Regents of the University of California and of Christos Zoulas; for the copyright notices, see route in the appendix Third-Party Copyright Notices.
/etc/autoconnect, netmanager, phlip, pppd, routed