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