2 .\" Copyright (C) 2009, Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH ROUTE 8 "May 13, 2017"
8 route \- manually manipulate the routing tables
12 \fBroute\fR [\fB-fnvq\fR] \fIsub-command\fR [ [\fImodifiers\fR] \fIargs\fR]
17 \fBroute\fR [\fB-fnvq\fR] [\fB-p\fR [\fB-R\fR \fIroot-dir\fR]] add | delete [\fImodifiers\fR] \fIdestination\fR \fIgateway\fR
23 \fBroute\fR [\fB-fnvq\fR] change | get [\fImodifiers\fR] \fIdestination\fR
24 [\fIgateway\fR [\fIargs\fR]]
29 \fBroute\fR [\fB-fn\fR] monitor [\fImodifiers\fR]
34 \fBroute\fR [\fB-fnvq\fR] flush [\fImodifiers\fR]
39 \fBroute\fR \fB-p\fR [\fB-R\fR \fIroot-dir\fR] show
44 \fBroute\fR manually manipulates the network routing tables. These tables are
45 normally maintained by the system routing daemon, such as \fBin.routed\fR(8)
46 and \fBin.ripngd\fR(8).
49 \fBroute\fR supports a limited number of general options, but a rich command
50 language. Users can specify an arbitrary request that can be delivered by means
51 of the programmatic interface discussed in \fBroute\fR(7P).
54 \fBroute\fR uses a routing socket and the new message types \fBRTM_ADD\fR,
55 \fBRTM_DELETE\fR, \fBRTM_GET\fR, and \fBRTM_CHANGE\fR. While only superusers
56 can modify routing tables, the \fBRTM_GET\fR operation is allowed for
64 Flush the routing tables of all gateway entries. If you use the \fB-f\fR option
65 in conjunction with any of the \fBroute\fR subcommands, \fBroute\fR flushes
66 the gateways before performing the subcommand. Specify the table to flush by
67 placing the \fBinet\fR or \fBinet6\fR modifier immediately after the \fB-f\fR
68 option. If unspecified, flushing IPv4 (\fBinet\fR) routes is the default.
77 Prevent attempts to print host and network names symbolically when reporting
78 actions. This option is useful when name servers are unavailable.
87 Make changes to the network route tables persistent across system restarts. The
88 operation is applied to the network routing tables first and, if successful, is
89 then applied to the list of saved routes used at system startup. In determining
90 whether an operation was successful, a failure to add a route that already
91 exists or to delete a route that is not in the routing table is ignored.
92 Particular care should be taken when using host or network names in persistent
93 routes, as network-based name resolution services are not available at the time
94 routes are added at startup.
109 \fB\fB-R\fR \fIroot-dir\fR\fR
112 Specify an alternate root directory where \fBroute\fR applies changes. This
113 option is ignored unless used in conjunction with the \fB-p\fR option. When
114 \fB-R\fR is specified, route changes are applied only to the list of saved
115 routes to be used at startup, \fBnot\fR to the network routing tables. In
116 addition, certain checks, such as the existence of network interfaces used with
117 \fB-ifp\fR, are skipped.
126 Print additional details in verbose mode.
131 The following subcommands are supported:
147 Change aspects of a route (such as its gateway).
156 Delete a specific route.
165 Remove all gateway entries from the routing table.
174 Look up and display the route for a destination.
183 Continuously report any changes to the routing information base, routing lookup
184 misses, or suspected network partitionings.
193 Display the list of routes to be applied at system startup. Can be used only in
194 conjunction with the \fB-p\fR option.
199 The \fBadd\fR and \fBdelete\fR subcommands have the following syntax:
203 route [ -fnvq ] cmd \fIdestination\fR \fIgateway\fR [metric/netmask]
210 where \fIcmd\fR is \fBadd\fR or \fBdelete\fR, \fIdestination\fR is the
211 destination host or network, and \fIgateway\fR is the next-hop intermediary
212 through which packets should be routed. Modifiers described in \fBOPERANDS\fR
213 can be placed anywhere on the command line.
216 The \fBget\fR and \fBchange\fR subcommands have the following syntax:
220 route [ -fnvq ] \fIcmd\fR \fIdestination\fR [\fIgateway\fR [metric/netmask]]
227 where \fIcmd\fR is \fBget\fR or \fBchange\fR, \fIdestination\fR is the
228 destination host or network, and \fIgateway\fR is the next-hop intermediary
229 through which packets should be routed. Modifiers described in \fBOPERANDS\fR
230 can be placed anywhere on the command line.
233 The \fBmonitor\fR subcommand has the following syntax:
237 route monitor [ -inet | -inet6 ]
244 \fBroute\fR executes its subcommands on routes to destinations by way of
246 .SS "Destinations and Gateways"
248 By default, destination and gateway addresses are interpreted as IPv4
249 addresses. All symbolic names are tried first as a host name, using
250 \fBgetipnodebyname\fR(3SOCKET). If this lookup fails in the AF_INET case,
251 \fBgetnetbyname\fR(3SOCKET) interprets the name as that of a network.
254 Including an optional modifier on the command line before the address changes
255 how the \fBroute\fR subcommand interprets it.
258 The following modifiers are supported:
265 Force the address to be interpreted as an IPv4 address, that is, under the
266 \fBAF_INET\fR address family.
275 Force the address to be interpreted as an IPv6 address, that is, under the
276 \fBAF_INET6\fR address family.
281 For IPv4 addresses, routes to a particular host are by default distinguished
282 from those to a network by interpreting the Internet address specified as the
283 destination. If the destination has a \fBlocal address part\fR (that is, the
284 portion not covered by the netmask) of \fB0\fR, or if the destination is
285 resolved as the symbolic name of a network, then the route is assumed to be to
286 a network; otherwise, it is presumed to be a route to a host.
289 You can force this selection by using one of the following modifiers:
296 Force the destination to be interpreted as a host.
305 Force the destination to be interpreted as a network.
317 Destination Destination Equivalent
319 \fB128.32\fR \fB-host\fR \fB128.0.0.32\fR
320 \fB128.32.130\fR \fB-host\fR \fB128.32.0.130\fR
321 \fB-net\fR \fB128.32\fR \fB128.32.0.0\fR
322 \fB-net\fR \fB128.32.130\fR \fB\fR\fB128.32.130.0\fR
327 Two modifiers avoid confusion between addresses and keywords (for example.,
328 \fBhost\fR used as a symbolic host name). You can distinguish a
329 \fIdestination\fR by preceding it with the \fB-dst\fR modifier. You can
330 distinguish a gateway address by using the \fB-gateway\fR modifier. If the
331 destination is directly reachable by way of an interface requiring no
332 intermediary IP router to act as a gateway, this can be indicated by using the
333 \fB-interface\fR or \fB-iface\fR modifier.
336 In the following example, the route does not refer to an external gateway
337 (router), but rather to one of the machine's interfaces. Packets with IP
338 destination addresses matching the destination and mask on such a route are
339 sent out on the interface identified by the gateway address. For interfaces
340 using the ARP protocol, this type of route is used to specify that all matching
341 destinations are local to the physical link. That is, a host could be
342 configured to ARP for all addresses, without regard to the configured interface
343 netmask, by adding a default route using this command. For example:
347 example# route add default \fIhostname\fR -interface
354 where gateway address \fIhostname\fR is the name or IP address associated with
355 the network interface over which all matching packets should be sent. On a host
356 with a single network interface, \fIhostname\fR is usually the same as the
357 \fInodename\fR returned by the \fBuname -n\fR command. See \fBuname\fR(1).
360 For backward compatibility with older systems, directly reachable routes can
361 also be specified by placing a \fB0\fR after the gateway address:
365 example# route add default \fIhostname\fR 0
372 This value was once a route metric, but this metric is no longer used. If the
373 value is specified as \fB0\fR, then the destination is directly reachable
374 (equivalent to specifying \fB-\fR\fBinterface\fR). If it is non-zero but cannot
375 be interpreted as a subnet mask, then a gateway is used (default).
378 With the \fBAF_INET\fR address family or an IPv4 address, a separate subnet
379 mask can be specified. This can be specified in one of the following ways:
384 IP address following the gateway address . This is typically specified in
385 \fIdecimal dot\fR notation as for \fBinet_addr\fR(3) rather than in
392 IP address following the \fB-netmask\fR qualifier.
398 Slash character and a decimal length appended to the destination address.
402 If a subnet mask is not specified, the mask used is the subnet mask of the
403 output interface selected by the gateway address, if the classful network of
404 the destination is the same as the classful network of the interface.
405 Otherwise, the classful network mask for the destination address is used.
408 Each of the following examples creates an IPv4 route to the destination
409 \fB192.0.2.32\fR subnet with a subnet mask of \fB255.255.255.224\fR:
413 example# route add 192.0.2.32/27 somegateway
414 example# route add 192.0.2.32 -netmask 255.255.255.224 somegateway
415 example# route add 192.0.2.32 somegateway 255.255.255.224
422 For IPv6, only the slash format is accepted. The following example creates an
423 IPv6 route to the destination \fB33fe::\fR with a netmask of \fB16\fR one-bits
424 followed by 112 zero-bits.
428 example# route add -inet6 3ffe::/16 somegateway
435 In cases where the gateway does not uniquely identify the output interface (for
436 example, when several interfaces have the same address), you can use the
437 \fB-ifp\fR \fIifname\fR modifier to specify the interface by name. For
438 example, \fB\fR\fB-ifp\fR \fBlo0\fR associates the route with the \fBlo0\fR
439 interface. If the named interface is an underlying interface in an IPMP (IP
440 multipathing) group, then requests to add a route will automatically be
441 translated to the corresponding IPMP IP interface, and requests to delete or
442 change a route on an underlying interface will fail.
445 Routes have associated flags that influence operation of the protocols when
446 sending to destinations matched by the routes. These flags can be set (and in
447 some cases cleared, indicated by \fB~\fR) by including the following modifiers
455 Modifier Flag Description
457 \fB-interface\fR \fB~RTF_GATEWAY\fR Destination is directly reachable
458 \fB-iface\fR \fB~RTF_GATEWAY\fR Alias for interface modifier
459 \fB-static\fR \fBRTF_STATIC\fR Manually added route
460 \fB-nostatic\fR \fB~RTF_STATIC\fR T{
461 Pretend route was added by kernel or routing daemon
463 \fB-reject\fR \fBRTF_REJECT\fR Emit an ICMP unreachable when matched
464 \fB-blackhole\fR \fBRTF_BLACKHOLE\fR Silently discard packets duing updates
465 \fB-proto1\fR \fBRTF_PROTO1\fR Set protocol specific routing flag #1
466 \fB-proto2\fR \fBRTF_PROTO2\fR Set protocol specific routing flag #2
467 \fB-private\fR \fBRTF_PRIVATE\fR Do not advertise this route
468 \fB-setsrc\fR \fBRTF_SETSRC\fR Assigns the default source address
473 The optional modifiers \fB-rtt\fR, \fB-rttvar\fR, \fB-sendpipe\fR,
474 \fB-recvpipe\fR, \fB-mtu\fR, \fB-hopcount\fR, \fB-expire\fR, and
475 \fB-ssthresh\fR provide initial values to quantities maintained in the routing
476 entry by transport level protocols, such as \fBTCP\fR. These can be
477 individually locked either by preceding each modifier to be locked by the
478 \fB-lock\fR meta-modifier, or by specifying that all ensuing metrics can be
479 locked by the \fB-lockrest\fR meta-modifier.
482 Some transport layer protocols can support only some of these metrics. The
483 following optional modifiers are supported:
490 Lifetime for the entry. This optional modifier is not currently supported.
496 \fB\fB-hopcount\fR\fR
499 Maximum hop count. This optional modifier is not currently supported.
508 Maximum MTU in bytes.
514 \fB\fB-recvpipe\fR\fR
517 Receive pipe size in bytes.
526 Round trip time in microseconds.
535 Round trip time variance in microseconds.
541 \fB\fB-sendpipe\fR\fR
544 Send pipe size in bytes.
550 \fB\fB-ssthresh\fR\fR
553 Send pipe size threshold in bytes.
558 The modifiers \fBhost\fR and \fBnet\fR are taken to be equivalent to
559 \fB-\fR\fBhost\fR and \fB-net\fR\fB\fR. To specify a symbolic address that
560 matches one of these names, use the \fBdst\fR or \fBgateway\fR keyword to
561 distinguish it. For example: \fB\fR\fB-dst\fR \fBhost\fR
564 The following two flags are also accepted for compatibility with older systems,
574 \fB-cloning\fR RTF_CLONING
575 \fB-xresolve\fR RTF_XRESOLVE
580 The \fB\fR\fB-ifa\fR \fBhostname\fR modifier is also accepted, but has no
585 \fB\fB/etc/defaultrouter\fR\fR
588 List of default routers
594 \fB\fB/etc/hosts\fR\fR
597 List of host names and net addresses
603 \fB\fB/etc/networks\fR\fR
606 List of network names and addresses
611 \fBuname\fR(1), \fBin.ripngd\fR(8), \fBin.routed\fR(8), \fBnetstat\fR(8),
612 \fBrouted\fR(8), \fBioctl\fR(2), \fBgetipnodebyname\fR(3SOCKET),
613 \fBgetnetbyname\fR(3), \fBinet_addr\fR(3), \fBdefaultrouter\fR(4),
614 \fBhosts\fR(4), \fBnetworks\fR(4), \fBattributes\fR(5), \fBARP\fR(7P),
615 \fBip\fR(7P), \fBroute\fR(7P), \fBrouting\fR(7P)
619 \fB\fBadd\fR [ \fBhost\fR\||\ \fBnetwork\|]\fR \fIdestination\fR:\fIgateway\fR
624 The specified route is being added to the tables. The values printed are from
625 the routing table entry supplied in the \fBioctl\fR(2) call. If the gateway
626 address used was not the primary address of the gateway (the first one returned
627 by \fBgetipnodebyname\fR(3SOCKET)) the gateway address is printed numerically
628 as well as symbolically.
634 \fB\fBdelete\fR [ \fBhost\fR\||\ \fBnetwork\fR\|]
635 \fIdestination\fR:\fIgateway\fR \fIflags\fR\fR
639 \fB\fBchange\fR [ \fBhost\fR\||\ \fBnetwork\fR\|]
640 \fIdestination\fR:\fIgateway\fR \fIflags\fR\fR
644 As \fBadd\fR, but when deleting or changing an entry.
650 \fB\fIdestination\fR \fBdone\fR\fR
654 When the \fB-f\fR flag is specified, or the \fBflush\fR subcommand is used,
655 each routing table entry deleted is indicated with a message of this form.
661 \fB\fBNetwork is unreachable\fR\fR
665 An attempt to add a route failed because the gateway listed was not on a
666 directly-connected network. Give the next-hop gateway instead.
672 \fB\fBnot in table\fR\fR
676 A \fBdelete\fR operation was attempted for an entry that is not in the table.
682 \fB\fBentry exists\fR\fR
686 An \fBadd\fR operation was attempted for a route that already exists in the
693 \fB\fBrouting table overflow\fR\fR
697 An operation was attempted, but the system was unable to allocate memory to
698 create the new entry.
704 \fB\fBinsufficient privileges\fR\fR
708 An attempt to add, delete, change, or flush a route failed because the calling
709 process does not have appropriate privileges.
714 Specifying that destinations are local (with the \fB-interface\fRmodifier)
715 assumes that the routers implement \fBproxy ARP\fR, meaning that they respond
716 to ARP queries for all reachable destinations. Normally, using either router
717 discovery or RIP is more reliable and scalable than using proxy ARP. See
718 \fBin.routed\fR(8) for information related to RIP.
721 Combining the all destinations are local route with subnet or network routes
722 can lead to unpredictable results. The search order as it relates to the all
723 destinations are local route are undefined and can vary from release to