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