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