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