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