|ROUTE(8)||System Manager's Manual||ROUTE(8)|
] command [
routeis a utility used to manually view and manipulate the network routing tables. Except for setting up the default route, it normally is not needed to manipulate routes, as a system routing table management daemon, such as ripd(8), ospfd(8), or bgpd(8), should tend to this task.
routecan be used to modify nearly any aspect of the routing policy, except packet forwarding, which can be manipulated through the sysctl(8) command. The
routeutility supports a limited number of general options, but a rich command language enables the user to specify any arbitrary request that could be delivered via the programmatic interface discussed in route(4). The options are as follows:
routeutility provides the following simple commands:
-gatewayis specified, only routes whose gateway are in the same address family as the destination are shown.
-ifacemodifier is used only interface specific messages (link state changes) are shown.
-gatewayis specified, only routes whose gateway are in the same address family as the destination are shown. If
-labelis specified, only routes with the specified label are shown. If
-priorityis specified, only routes with the specified (numeric) priority are shown. Some well-known priorities can be given by name. If the priority is negative, then routes that do not match the numeric priority are shown.
-hostcause the destination to be interpreted as a network or a host, respectively. Otherwise, type is chosen based on the following rules: The route is assumed to be to a network if any of the following apply to destination:
192.168.1.1is interpreted as
192.168.1is interpreted as
192.168.1. Note, however, that
192.168.2.0will be interpreted as
192.168.2.0since it is a complete IP address with 3 dots. In this case the number of bits in the network portion of the address must be explicitly listed, for example
192.168.2/24, or alternately
192.168.2. If the destination is directly reachable via an interface requiring no intermediary system to act as a gateway, the
-ifacemodifier should be specified; the gateway given is the address of this host on the common network, indicating the interface to be used for transmission. To allow addresses to be interpreted as belonging to a particular address family (as well as for use in the family arguments to some commands), the following modifiers may be used:
-linkspecifies that all subsequent addresses are specified as link-level addresses, and the names must be numeric specifications rather than symbolic names. The optional
-netmaskqualifier is intended to manually add subnet routes with netmasks different from that of the implied network interface (as would otherwise be communicated using a routing protocol). One specifies an additional ensuing address parameter (to be interpreted as a network mask). The implicit network mask generated in the
AF_INETcase can be overridden by making sure this option follows the destination parameter.
-prefixlenis also available for a similar purpose, for IPv6/v4. A specific routing priority can be specified with the optional
-priorityqualifier. If no priority is specified the kernel will set a priority depending on the RTF_STATIC flag to either RTP_STATIC or RTP_DEFAULT. Note that priority 1 is reserved for kernel use. The optional
-mpathmodifier needs to be specified with the
addcommand to be able to enter multiple gateways for the same destination address (multipath). When multiple routes exist for a destination, one route is selected based on the source address of the packet. The sysctl(8) variables net.inet.ip.multipath and net.inet6.ip6.multipath are used to control multipath routing. If set to 1, multiple routes with the same priority are used equally; if set to 0, the first route selected will be used for subsequent packets to that destination regardless of source. When inserting MPLS routes, particular modifiers must be used. The
-mplslabelmodifier needs to be specified in an ingress LSR to associate a particular label to an IPv4/IPv6 route. The MPLS traffic
-outmodifiers are intended to identify the ingress label and, optionally, the outgoing one. Additionally, one of the following operations must be used:
-swap. Route's nexthop can be specified with the modifier
-inet. 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:
||silently discard pkts (during updates)|
||generates a new route on use|
||destination is directly reachable|
||validly translates proto addr to link addr|
||multiple gateways for a destination exist|
||pretend route added by kernel or daemon|
||set protocol specific routing flag #1|
||set protocol specific routing flag #2|
||emit an ICMP unreachable when matched|
||manually added route|
-mtuprovide initial values to quantities maintained in the routing entry by transport level protocols, such as TCP (see tcp(4)). They have the following meanings:
-lockmeta-modifier, or one can specify that all ensuing metrics may be locked by the
-lockrestmeta-modifier. In a
addcommand where the destination and gateway are not sufficient to specify the route, the
-ifamodifiers may be used to determine the interface name or interface address. The optional
-labelmodifier specifies on route addition or modification that the route should have the given label associated with it. Route labels can be used to attach arbitrary information to a route. All symbolic names specified for a destination or gateway are looked up first as a network name using getnetbyname(3). If this lookup fails, gethostbyname(3) is then used to interpret the name as a valid host name.
routeuses a routing socket (see route(4)) and the message types
RTM_CHANGE. As such, only the superuser may modify the routing tables.
# route add -inet 192.168.5.0/24 192.168.0.1
# route change -inet 192.168.5.0/24 192.168.0.2
# route delete -inet 192.168.5.0/24
flushcommand is specified, each routing table entry deleted is indicated with a message of this form.
deleteoperation was attempted for an entry which wasn't present in the tables.
addoperation was attempted, but the system was low on resources and was unable to allocate memory to create the new entry.
routecommand appeared in 4.2BSD. IPv6 support was added by WIDE/KAME project. The
-rttvarmodifiers used to be used to initialize various quantities in routing table entries. The routing system no longer uses these values and the modifiers exist now only for compatibility with other operating systems.
-ifpmodifiers with the
addcommand will incorrectly fail with a “Network is unreachable” message if there is no default route. See case
route_output() from sys/net/rtsock.c for details.
|January 1, 2017||OpenBSD-6.1|