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