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