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