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