1.\" Copyright (c) 1983, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. All advertising materials mentioning features or use of this software 13.\" must display the following acknowledgement: 14.\" This product includes software developed by the University of 15.\" California, Berkeley and its contributors. 16.\" 4. Neither the name of the University nor the names of its contributors 17.\" may be used to endorse or promote products derived from this software 18.\" without specific prior written permission. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" @(#)route.8 8.3 (Berkeley) 3/19/94 33.\" $FreeBSD: src/sbin/route/route.8,v 1.17.2.9 2003/02/24 00:56:43 trhodes Exp $ 34.\" $DragonFly: src/sbin/route/route.8,v 1.5 2006/01/19 22:19:30 dillon Exp $ 35.\" 36.Dd June 8, 2001 37.Dt ROUTE 8 38.Os 39.Sh NAME 40.Nm route 41.Nd manually manipulate the routing tables 42.Sh SYNOPSIS 43.Nm 44.Op Fl dnqtv 45.Op Fl c Ar cpu 46.Ar command 47.Oo 48.Op Ar modifiers 49.Ar args 50.Oc 51.Sh DESCRIPTION 52The 53.Nm 54utility is used to manually manipulate the network 55routing tables. It normally is not needed, as a 56system routing table management daemon such as 57.Xr routed 8 , 58should tend to this task. 59.Pp 60The 61.Nm 62utility supports a limited number of general options, 63but a rich command language, enabling the user to specify 64any arbitrary request that could be delivered via the 65programmatic interface discussed in 66.Xr route 4 . 67.Pp 68The following options are available: 69.Bl -tag -width indent 70.It Fl c Ar cpu 71On SMP systems the route table is replicated. This option allows the 72route table for a specific cpu to be accessed and exists primarily 73for debugging purposes. 74.It Fl n 75Bypass attempts to print host and network names symbolically 76when reporting actions. (The process of translating between symbolic 77names and numerical equivalents can be quite time consuming, and 78may require correct operation of the network; thus it may be expedient 79to forget this, especially when attempting to repair networking operations). 80.It Fl v 81(verbose) Print additional details. 82.It Fl q 83Suppress all output from the 84.Cm add , delete , 85and 86.Cm flush 87commands. 88.It Fl w 89Print the full width of the data being represented even if it would overflow 90the column. 91.El 92.Pp 93The 94.Nm 95utility provides six commands: 96.Pp 97.Bl -tag -width Fl -compact 98.It Cm add 99Add a route. 100.It Cm flush 101Remove all routes. 102.It Cm delete 103Delete a specific route. 104.It Cm change 105Change aspects of a route (such as its gateway). 106.It Cm get 107Lookup and display the route for a destination. 108.It Cm show 109Print out the route table similar to "netstat \-r" (see 110.Xr netstat 1 ) . 111.It Cm monitor 112Continuously report any changes to the routing information base, 113routing lookup misses, or suspected network partitionings. 114.El 115.Pp 116The monitor command has the syntax: 117.Pp 118.Bd -ragged -offset indent -compact 119.Nm 120.Op Fl n 121.Cm monitor 122.Ed 123.Pp 124The flush command has the syntax: 125.Pp 126.Bd -ragged -offset indent -compact 127.Nm 128.Op Fl n 129.Cm flush 130.Op Ar family 131.Ed 132.Pp 133If the 134.Cm flush 135command is specified, 136.Nm 137will ``flush'' the routing tables of all gateway entries. 138When the address family may is specified by any of the 139.Fl osi , 140.Fl xns , 141.Fl atalk , 142.Fl inet6 , 143or 144.Fl inet 145modifiers, only routes having destinations with addresses in the 146delineated family will be deleted. 147.Pp 148The other commands have the following syntax: 149.Pp 150.Bd -ragged -offset indent -compact 151.Nm 152.Op Fl n 153.Ar command 154.Op Fl net No \&| Fl host 155.Ar destination gateway 156.Op Ar netmask 157.Ed 158.Pp 159where 160.Ar destination 161is the destination host or network, 162.Ar gateway 163is the next-hop intermediary via which packets should be routed. 164Routes to a particular host may be distinguished from those to 165a network by interpreting the Internet address specified as the 166.Ar destination 167argument. 168The optional modifiers 169.Fl net 170and 171.Fl host 172force the destination to be interpreted as a network or a host, respectively. 173Otherwise, if the 174.Ar destination 175has a 176.Dq local address part 177of 178INADDR_ANY 179.Pq Li 0.0.0.0 , 180or if the 181.Ar destination 182is the symbolic name of a network, then the route is 183assumed to be to a network; otherwise, it is presumed to be a 184route to a host. 185Optionally, the 186.Ar destination 187could also be specified in the 188.Ar net Ns / Ns Ar bits 189format. 190.Pp 191For example, 192.Li 128.32 193is interpreted as 194.Fl host Li 128.0.0.32 ; 195.Li 128.32.130 196is interpreted as 197.Fl host Li 128.32.0.130 ; 198.Fl net Li 128.32 199is interpreted as 200.Li 128.32.0.0; 201.Fl net Li 128.32.130 202is interpreted as 203.Li 128.32.130.0; 204and 205.Li 192.168.64/20 206is interpreted as 207.Fl net Li 192.168.64 Fl netmask Li 255.255.240.0 . 208.Pp 209A 210.Ar destination 211of 212.Ar default 213is a synonym for 214.Fl net Li 0.0.0.0 , 215which is the default route. 216.Pp 217If the destination is directly reachable 218via an interface requiring 219no intermediary system to act as a gateway, the 220.Fl interface 221modifier should be specified; 222the gateway given is the address of this host on the common network, 223indicating the interface to be used for transmission. 224Alternately, if the interface is point to point the name of the interface 225itself may be given, in which case the route remains valid even 226if the local or remote addresses change. 227.Pp 228The optional modifiers 229.Fl xns , 230.Fl osi , 231.Fl atalk , 232and 233.Fl link 234specify that all subsequent addresses are in the 235.Tn XNS , 236.Tn OSI , 237or 238.Tn AppleTalk 239address families, 240or are specified as link-level addresses, 241and the names must be numeric specifications rather than 242symbolic names. 243.Pp 244The optional 245.Fl netmask 246modifier is intended 247to achieve the effect of an 248.Tn OSI 249.Tn ESIS 250redirect with the netmask option, 251or to manually add subnet routes with 252netmasks different from that of the implied network interface 253(as would otherwise be communicated using the OSPF or ISIS routing protocols). 254One specifies an additional ensuing address parameter 255(to be interpreted as a network mask). 256The implicit network mask generated in the AF_INET case 257can be overridden by making sure this option follows the destination parameter. 258.Pp 259For 260.Dv AF_INET6 , 261the 262.Fl prefixlen 263qualifier 264is available instead of the 265.Fl mask 266qualifier because non-continuous masks are not allowed in IPv6. 267For example, 268.Fl prefixlen Li 32 269specifies network mask of 270.Li ffff:ffff:0000:0000:0000:0000:0000:0000 271to be used. 272The default value of prefixlen is 64 to get along with 273the aggregatable address. 274But 0 is assumed if 275.Cm default 276is specified. 277Note that the qualifier works only for 278.Dv AF_INET6 279address family. 280.Pp 281Routes have associated flags which influence operation of the protocols 282when sending to destinations matched by the routes. 283These flags may be set (or sometimes cleared) 284by indicating the following corresponding modifiers: 285.Bd -literal 286-cloning RTF_CLONING - generates a new route on use 287-xresolve RTF_XRESOLVE - emit mesg on use (for external lookup) 288-iface ~RTF_GATEWAY - destination is directly reachable 289-static RTF_STATIC - manually added route 290-nostatic ~RTF_STATIC - pretend route added by kernel or daemon 291-reject RTF_REJECT - emit an ICMP unreachable when matched 292-blackhole RTF_BLACKHOLE - silently discard pkts (during updates) 293-proto1 RTF_PROTO1 - set protocol specific routing flag #1 294-proto2 RTF_PROTO2 - set protocol specific routing flag #2 295-llinfo RTF_LLINFO - validly translates proto addr to link addr 296.Ed 297.Pp 298The optional modifiers 299.Fl rtt , 300.Fl rttvar , 301.Fl sendpipe , 302.Fl recvpipe , 303.Fl mtu , 304.Fl hopcount , 305.Fl expire , 306and 307.Fl ssthresh 308provide initial values to quantities maintained in the routing entry 309by transport level protocols, such as TCP or TP4. 310These may be individually locked by preceding each such modifier to 311be locked by 312the 313.Fl lock 314meta-modifier, or one can 315specify that all ensuing metrics may be locked by the 316.Fl lockrest 317meta-modifier. 318.Pp 319In a 320.Cm change 321or 322.Cm add 323command where the destination and gateway are not sufficient to specify 324the route (as in the 325.Tn ISO 326case where several interfaces may have the 327same address), the 328.Fl ifp 329or 330.Fl ifa 331modifiers may be used to determine the interface or interface address. 332.Pp 333The optional 334.Fl proxy 335modifier specifies that the 336.Dv RTF_LLINFO 337routing table entry is the 338.Dq published (proxy-only) 339.Tn ARP 340entry, as reported by 341.Xr arp 8 . 342.Pp 343All symbolic names specified for a 344.Ar destination 345or 346.Ar gateway 347are looked up first as a host name using 348.Xr gethostbyname 3 . 349If this lookup fails, 350.Xr getnetbyname 3 351is then used to interpret the name as that of a network. 352.Pp 353The 354.Nm 355utility uses a routing socket and the new message types 356.Dv RTM_ADD , RTM_DELETE , RTM_GET , 357and 358.Dv RTM_CHANGE . 359As such, only the super-user may modify 360the routing tables. 361.Sh DIAGNOSTICS 362.Bl -diag 363.It "add [host \&| network ] %s: gateway %s flags %x" 364The specified route is being added to the tables. The 365values printed are from the routing table entry supplied 366in the 367.Xr ioctl 2 368call. 369If the gateway address used was not the primary address of the gateway 370(the first one returned by 371.Xr gethostbyname 3 ) , 372the gateway address is printed numerically as well as symbolically. 373.It "delete [ host \&| network ] %s: gateway %s flags %x" 374As above, but when deleting an entry. 375.It "%s %s done" 376When the 377.Cm flush 378command is specified, each routing table entry deleted 379is indicated with a message of this form. 380.It "Network is unreachable" 381An attempt to add a route failed because the gateway listed was not 382on a directly-connected network. 383The next-hop gateway must be given. 384.It "not in table" 385A delete operation was attempted for an entry which 386wasn't present in the tables. 387.It "routing table overflow" 388An add operation was attempted, but the system was 389low on resources and was unable to allocate memory 390to create the new entry. 391.It "gateway uses the same route" 392A 393.Cm change 394operation resulted in a route whose gateway uses the 395same route as the one being changed. 396The next-hop gateway should be reachable through a different route. 397.El 398.Pp 399.Ex -std 400.Sh SEE ALSO 401.\".Xr esis 4 , 402.Xr netintro 4 , 403.Xr route 4 , 404.Xr arp 8 , 405.Xr IPXrouted 8 , 406.Xr routed 8 407.\".Xr XNSrouted 8 408.Sh HISTORY 409The 410.Nm 411utility appeared in 412.Bx 4.2 . 413.Sh BUGS 414The first paragraph may have slightly exaggerated 415.Xr routed 8 Ns 's 416abilities. 417