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