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 1M "Feb 3, 2009"
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
45 \fBroute\fR manually manipulates the network routing tables. These tables are
46 normally maintained by the system routing daemon, such as \fBin.routed\fR(1M)
47 and \fBin.ripngd\fR(1M).
50 \fBroute\fR supports a limited number of general options, but a rich command
51 language. Users can specify an arbitrary request that can be delivered by means
52 of the programmatic interface discussed in \fBroute\fR(7P).
55 \fBroute\fR uses a routing socket and the new message types \fBRTM_ADD\fR,
56 \fBRTM_DELETE\fR, \fBRTM_GET\fR, and \fBRTM_CHANGE\fR. While only superusers
57 can modify routing tables, the \fBRTM_GET\fR operation is allowed for
66 Flush the routing tables of all gateway entries. If you use the \fB-f\fR option
67 in conjunction with any of the \fBroute\fR sub-commands, \fBroute\fR flushes
68 the gateways before performing the sub-command. Specify the table to flush by
69 placing the \fBinet\fR or \fBinet6\fR modifier immediately after the \fB-f\fR
70 option. If unspecified, flushing IPv4 (\fBinet\fR) routes is the default.
79 Prevent attempts to print host and network names symbolically when reporting
80 actions. This option is useful when name servers are unavailable.
89 Make changes to the network route tables persistent across system restarts. The
90 operation is applied to the network routing tables first and, if successful, is
91 then applied to the list of saved routes used at system startup. In determining
92 whether an operation was successful, a failure to add a route that already
93 exists or to delete a route that is not in the routing table is ignored.
94 Particular care should be taken when using host or network names in persistent
95 routes, as network-based name resolution services are not available at the time
96 routes are added at startup.
111 \fB\fB-R\fR \fIroot-dir\fR\fR
114 Specify an alternate root directory where \fBroute\fR applies changes. This
115 option is ignored unless used in conjunction with the \fB-p\fR option. When
116 \fB-R\fR is specified, route changes are applied only to the list of saved
117 routes to be used at startup, \fBnot\fR to the network routing tables. In
118 addition, certain checks, such as the existence of network interfaces used with
119 \fB-ifp\fR, are skipped. This can be useful from within JumpStart scripts,
120 where the root directory of the system being modified is in a location other
130 Print additional details in verbose mode.
136 The following subcommands are supported:
152 Change aspects of a route (such as its gateway).
161 Delete a specific route.
170 Remove all gateway entries from the routing table.
179 Look up and display the route for a destination.
188 Continuously report any changes to the routing information base, routing lookup
189 misses, or suspected network partitionings.
198 Display the list of routes to be applied at system startup. Can be used only in
199 conjunction with the \fB-p\fR option.
204 The \fBadd\fR and \fBdelete\fR sub-commands have the following syntax:
208 route [ -fnvq ] cmd \fIdestination\fR \fIgateway\fR [metric/netmask]
215 where \fIcmd\fR is \fBadd\fR or \fBdelete\fR, \fIdestination\fR is the
216 destination host or network, and \fIgateway\fR is the next-hop intermediary
217 through which packets should be routed. Modifiers described in \fBOPERANDS\fR
218 can be placed anywhere on the command line.
221 The \fBget\fR and \fBchange\fR sub-commands have the following syntax:
225 route [ -fnvq ] \fIcmd\fR \fIdestination\fR [\fIgateway\fR [metric/netmask]]
232 where \fIcmd\fR is \fBget\fR or \fBchange\fR, \fIdestination\fR is the
233 destination host or network, and \fIgateway\fR is the next-hop intermediary
234 through which packets should be routed. Modifiers described in \fBOPERANDS\fR
235 can be placed anywhere on the command line.
238 The \fBmonitor\fR sub-command has the following syntax:
242 route monitor [ -inet | -inet6 ]
250 \fBroute\fR executes its sub-commands on routes to destinations by way of
252 .SS "Destinations and Gateways"
255 By default, destination and gateway addresses are interpreted as IPv4
256 addresses. All symbolic names are tried first as a host name, using
257 \fBgetipnodebyname\fR(3SOCKET). If this lookup fails in the AF_INET case,
258 \fBgetnetbyname\fR(3SOCKET) interprets the name as that of a network.
261 Including an optional modifier on the command line before the address changes
262 how the \fBroute\fR sub-command interprets it.
265 The following modifiers are supported:
272 Force the address to be interpreted as an IPv4 address, that is, under the
273 \fBAF_INET\fR address family.
282 Force the address to be interpreted as an IPv6 address, that is, under the
283 \fBAF_INET6\fR address family.
288 For IPv4 addresses, routes to a particular host are by default distinguished
289 from those to a network by interpreting the Internet address specified as the
290 destination. If the destination has a \fBlocal address part\fR (that is, the
291 portion not covered by the netmask) of \fB0\fR, or if the destination is
292 resolved as the symbolic name of a network, then the route is assumed to be to
293 a network; otherwise, it is presumed to be a route to a host.
296 You can force this selection by using one of the following modifiers:
303 Force the destination to be interpreted as a host.
312 Force the destination to be interpreted as a network.
324 Destination Destination Equivalent
326 \fB128.32\fR \fB-host\fR \fB128.0.0.32\fR
327 \fB128.32.130\fR \fB-host\fR \fB128.32.0.130\fR
328 \fB-net\fR \fB128.32\fR \fB128.32.0.0\fR
329 \fB-net\fR \fB128.32.130\fR \fB\fR\fB128.32.130.0\fR
334 Two modifiers avoid confusion between addresses and keywords (for example.,
335 \fBhost\fR used as a symbolic host name). You can distinguish a
336 \fIdestination\fR by preceding it with the \fB-dst\fR modifier. You can
337 distinguish a gateway address by using the \fB-gateway\fR modifier. If the
338 destination is directly reachable by way of an interface requiring no
339 intermediary IP router to act as a gateway, this can be indicated by using the
340 \fB-interface\fR or \fB-iface\fR modifier.
343 In the following example, the route does not refer to an external gateway
344 (router), but rather to one of the machine's interfaces. Packets with IP
345 destination addresses matching the destination and mask on such a route are
346 sent out on the interface identified by the gateway address. For interfaces
347 using the ARP protocol, this type of route is used to specify that all matching
348 destinations are local to the physical link. That is, a host could be
349 configured to ARP for all addresses, without regard to the configured interface
350 netmask, by adding a default route using this command. For example:
354 example# route add default \fIhostname\fR -interface
361 where gateway address \fIhostname\fR is the name or IP address associated with
362 the network interface over which all matching packets should be sent. On a host
363 with a single network interface, \fIhostname\fR is usually the same as the
364 \fInodename\fR returned by the \fBuname -n\fR command. See \fBuname\fR(1).
367 For backward compatibility with older systems, directly reachable routes can
368 also be specified by placing a \fB0\fR after the gateway address:
372 example# route add default \fIhostname\fR 0
379 This value was once a route metric, but this metric is no longer used. If the
380 value is specified as \fB0\fR, then the destination is directly reachable
381 (equivalent to specifying \fB-\fR\fBinterface\fR). If it is non-zero but cannot
382 be interpreted as a subnet mask, then a gateway is used (default).
385 With the \fBAF_INET\fR address family or an IPv4 address, a separate subnet
386 mask can be specified. This can be specified in one of the following ways:
391 IP address following the gateway address . This is typically specified in
392 \fIdecimal dot\fR notation as for \fBinet_addr\fR(3SOCKET) rather than in
399 IP address following the \fB-netmask\fR qualifier.
405 Slash character and a decimal length appended to the destination address.
409 If a subnet mask is not specified, the mask used is the subnet mask of the
410 output interface selected by the gateway address, if the classful network of
411 the destination is the same as the classful network of the interface.
412 Otherwise, the classful network mask for the destination address is used.
415 Each of the following examples creates an IPv4 route to the destination
416 \fB192.0.2.32\fR subnet with a subnet mask of \fB255.255.255.224\fR:
420 example# route add 192.0.2.32/27 somegateway
421 example# route add 192.0.2.32 -netmask 255.255.255.224 somegateway
422 example# route add 192.0.2.32 somegateway 255.255.255.224
429 For IPv6, only the slash format is accepted. The following example creates an
430 IPv6 route to the destination \fB33fe::\fR with a netmask of \fB16\fR one-bits
431 followed by 112 zero-bits.
435 example# route add -inet6 3ffe::/16 somegateway
442 In cases where the gateway does not uniquely identify the output interface (for
443 example, when several interfaces have the same address), you can use the
444 \fB-ifp\fR \fIifname\fR modifier to specify the interface by name. For
445 example, \fB\fR\fB-ifp\fR \fBlo0\fR associates the route with the \fBlo0\fR
446 interface. If the named interface is an underlying interface in an IPMP (IP
447 multipathing) group, then requests to add a route will automatically be
448 translated to the corresponding IPMP IP interface, and requests to delete or
449 change a route on an underlying interface will fail.
453 Routes have associated flags that influence operation of the protocols when
454 sending to destinations matched by the routes. These flags can be set (and in
455 some cases cleared, indicated by \fB~\fR) by including the following modifiers
463 Modifier Flag Description
465 \fB-interface\fR \fB~RTF_GATEWAY\fR Destination is directly reachable
466 \fB-iface\fR \fB~RTF_GATEWAY\fR Alias for interface modifier
467 \fB-static\fR \fBRTF_STATIC\fR Manually added route
468 \fB-nostatic\fR \fB~RTF_STATIC\fR T{
469 Pretend route was added by kernel or routing daemon
471 \fB-reject\fR \fBRTF_REJECT\fR Emit an ICMP unreachable when matched
472 \fB-blackhole\fR \fBRTF_BLACKHOLE\fR Silently discard packets duing updates
473 \fB-proto1\fR \fBRTF_PROTO1\fR Set protocol specific routing flag #1
474 \fB-proto2\fR \fBRTF_PROTO2\fR Set protocol specific routing flag #2
475 \fB-private\fR \fBRTF_PRIVATE\fR Do not advertise this route
476 \fB-multirt\fR \fBRTF_MULTIRT\fR Creates the specified redundant route
477 \fB-setsrc\fR \fBRTF_SETSRC\fR Assigns the default source address
482 The optional modifiers \fB-rtt\fR, \fB-rttvar\fR, \fB-sendpipe\fR,
483 \fB-recvpipe\fR, \fB-mtu\fR, \fB-hopcount\fR, \fB-expire\fR, and
484 \fB-ssthresh\fR provide initial values to quantities maintained in the routing
485 entry by transport level protocols, such as \fBTCP\fR. These can be
486 individually locked either by preceding each modifier to be locked by the
487 \fB-lock\fR meta-modifier, or by specifying that all ensuing metrics can be
488 locked by the \fB-lockrest\fR meta-modifier.
491 Some transport layer protocols can support only some of these metrics. The
492 following optional modifiers are supported:
499 Lifetime for the entry. This optional modifier is not currently supported.
505 \fB\fB-hopcount\fR\fR
508 Maximum hop count. This optional modifier is not currently supported.
517 Maximum MTU in bytes.
523 \fB\fB-recvpipe\fR\fR
526 Receive pipe size in bytes.
535 Round trip time in microseconds.
544 Round trip time variance in microseconds.
550 \fB\fB-sendpipe\fR\fR
553 Send pipe size in bytes.
559 \fB\fB-ssthresh\fR\fR
562 Send pipe size threshold in bytes.
571 Security attributes of the route. This modifier is available only if the system
572 is configured with the Solaris Trusted Extensions feature.
574 The \fB-secattr\fR modifier has the following format:
578 min_sl=\fIval\fR,max_sl=\fIval\fR,doi=\fIval\fR,cipso
590 In the first form, above, the \fIval\fR for \fBmin_sl\fR and \fBmax_sl\fR is a
591 sensitivity label in either hex or string form. The \fIval\fR for \fBdoi\fR is
592 a non-negative integer. The route will apply only for packets with the same
593 domain of interpretation as defined by the \fBdoi\fR value and within the
594 accreditation range defined by the \fBmin_sl\fR and \fBmax_sl\fR values. The
595 \fBcipso\fR keyword is optional and set by default. Valid \fBmin_sl\fR,
596 \fBmax_sl\fR and \fBdoi\fR keyword/value pairs are mandatory. Note that if
597 \fIval\fR contains a space, it must be protected by double quotes.
599 The second form, above, is equivalent to specifying the first form with the
600 same \fBVAL\fR for \fBmin_sl\fR and \fBmax_sl\fR. The second form should be
601 used for the \fBget\fR command, because \fBget\fR uses only a single
608 The modifiers \fBhost\fR and \fBnet\fR are taken to be equivalent to
609 \fB-\fR\fBhost\fR and \fB-net\fR\fB\fR. To specify a symbolic address that
610 matches one of these names, use the \fBdst\fR or \fBgateway\fR keyword to
611 distinguish it. For example: \fB\fR\fB-dst\fR \fBhost\fR
614 The following two flags are also accepted for compatibility with older systems,
624 \fB-cloning\fR RTF_CLONING
625 \fB-xresolve\fR RTF_XRESOLVE
630 The \fB\fR\fB-ifa\fR \fBhostname\fR modifier is also accepted, but has no
636 \fB\fB/etc/defaultrouter\fR\fR
639 List of default routers
645 \fB\fB/etc/hosts\fR\fR
648 List of host names and net addresses
654 \fB\fB/etc/networks\fR\fR
657 List of network names and addresses
663 \fBuname\fR(1), \fBin.ripngd\fR(1M), \fBin.routed\fR(1M), \fBnetstat\fR(1M),
664 \fBrouted\fR(1M), \fBioctl\fR(2), \fBgetipnodebyname\fR(3SOCKET),
665 \fBgetnetbyname\fR(3SOCKET), \fBinet_addr\fR(3SOCKET), \fBdefaultrouter\fR(4),
666 \fBhosts\fR(4), \fBnetworks\fR(4), \fBattributes\fR(5), \fBARP\fR(7P),
667 \fBip\fR(7P), \fBroute\fR(7P), \fBrouting\fR(7P)
672 \fB\fBadd\fR [ \fBhost\fR\||\ \fBnetwork\|]\fR \fIdestination\fR:\fIgateway\fR
677 The specified route is being added to the tables. The values printed are from
678 the routing table entry supplied in the \fBioctl\fR(2) call. If the gateway
679 address used was not the primary address of the gateway (the first one returned
680 by \fBgetipnodebyname\fR(3SOCKET)) the gateway address is printed numerically
681 as well as symbolically.
687 \fB\fBdelete\fR [ \fBhost\fR\||\ \fBnetwork\fR\|]
688 \fIdestination\fR:\fIgateway\fR \fIflags\fR\fR
692 \fB\fBchange\fR [ \fBhost\fR\||\ \fBnetwork\fR\|]
693 \fIdestination\fR:\fIgateway\fR \fIflags\fR\fR
697 As \fBadd\fR, but when deleting or changing an entry.
703 \fB\fIdestination\fR \fBdone\fR\fR
707 When the \fB-f\fR flag is specified, or the \fBflush\fR sub-command is used,
708 each routing table entry deleted is indicated with a message of this form.
714 \fB\fBNetwork is unreachable\fR\fR
718 An attempt to add a route failed because the gateway listed was not on a
719 directly-connected network. Give the next-hop gateway instead.
725 \fB\fBnot in table\fR\fR
729 A \fBdelete\fR operation was attempted for an entry that is not in the table.
735 \fB\fBentry exists\fR\fR
739 An \fBadd\fR operation was attempted for a route that already exists in the
746 \fB\fBrouting table overflow\fR\fR
750 An operation was attempted, but the system was unable to allocate memory to
751 create the new entry.
757 \fB\fBinsufficient privileges\fR\fR
761 An attempt to add, delete, change, or flush a route failed because the calling
762 process does not have appropriate privileges.
768 Specifying that destinations are local (with the \fB-interface\fRmodifier)
769 assumes that the routers implement \fBproxy ARP\fR, meaning that they respond
770 to ARP queries for all reachable destinations. Normally, using either router
771 discovery or RIP is more reliable and scalable than using proxy ARP. See
772 \fBin.routed\fR(1M) for information related to RIP.
775 Combining the all destinations are local route with subnet or network routes
776 can lead to unpredictable results. The search order as it relates to the all
777 destinations are local route are undefined and can vary from release to