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