xref: /freebsd/sbin/route/route.8 (revision 4cf49a43559ed9fdad601bdcccd2c55963008675)
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 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 forgo 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
153.Dq local address part
154of
155INADDR_ANY
156.Pq Li 0.0.0.0 ,
157or if the
158.Ar destination
159is the symbolic name of a network, then the route is
160assumed to be to a network; otherwise, it is presumed to be a
161route to a host.
162.Pp
163For example,
164.Li 128.32
165is interpreted as
166.Fl host Li 128.0.0.32 ;
167.Li 128.32.130
168is interpreted as
169.Fl host Li 128.32.0.130 ;
170.Fl net Li 128.32
171is interpreted as
172.Li 128.32.0.0;
173and
174.Fl net Li 128.32.130
175is interpreted as
176.Li 128.32.130.0 .
177.Pp
178A
179.Ar destination
180of
181.Ar default
182is a synonym for
183.Fl net Li 0.0.0.0 ,
184which is the default route.
185.Pp
186If the destination is directly reachable
187via an interface requiring
188no intermediary system to act as a gateway, the
189.Fl interface
190modifier should be specified;
191the gateway given is the address of this host on the common network,
192indicating the interface to be used for transmission.
193Alternately, if the interface is point to point the name of the interface
194itself may be given, in which case the route remains valid even
195if the local or remote addresses change.
196.Pp
197The optional modifiers
198.Fl xns ,
199.Fl osi ,
200.Fl atalk ,
201and
202.Fl link
203specify that all subsequent addresses are in the
204.Tn XNS ,
205.Tn OSI ,
206or
207.Tn AppleTalk
208address families,
209or are specified as link-level addresses,
210and the names must be numeric specifications rather than
211symbolic names.
212.Pp
213The optional
214.Fl netmask
215modifier is intended
216to achieve the effect of an
217.Tn OSI
218.Tn ESIS
219redirect with the netmask option,
220or to manually add subnet routes with
221netmasks different from that of the implied network interface
222(as would otherwise be communicated using the OSPF or ISIS routing protocols).
223One specifies an additional ensuing address parameter
224(to be interpreted as a network mask).
225The implicit network mask generated in the AF_INET case
226can be overridden by making sure this option follows the destination parameter.
227.Pp
228Routes have associated flags which influence operation of the protocols
229when sending to destinations matched by the routes.
230These flags may be set (or sometimes cleared)
231by indicating the following corresponding modifiers:
232.Bd -literal
233-cloning   RTF_CLONING    - generates a new route on use
234-xresolve  RTF_XRESOLVE   - emit mesg on use (for external lookup)
235-iface    ~RTF_GATEWAY    - destination is directly reachable
236-static    RTF_STATIC     - manually added route
237-nostatic ~RTF_STATIC     - pretend route added by kernel or daemon
238-reject    RTF_REJECT     - emit an ICMP unreachable when matched
239-blackhole RTF_BLACKHOLE  - silently discard pkts (during updates)
240-proto1    RTF_PROTO1     - set protocol specific routing flag #1
241-proto2    RTF_PROTO2     - set protocol specific routing flag #2
242-llinfo    RTF_LLINFO     - validly translates proto addr to link addr
243.Ed
244.Pp
245The optional modifiers
246.Fl rtt ,
247.Fl rttvar ,
248.Fl sendpipe ,
249.Fl recvpipe ,
250.Fl mtu ,
251.Fl hopcount ,
252.Fl expire ,
253and
254.Fl ssthresh
255provide initial values to quantities maintained in the routing entry
256by transport level protocols, such as TCP or TP4.
257These may be individually locked by preceding each such modifier to
258be locked by
259the
260.Fl lock
261meta-modifier, or one can
262specify that all ensuing metrics may be locked by the
263.Fl lockrest
264meta-modifier.
265.Pp
266In a
267.Cm change
268or
269.Cm add
270command where the destination and gateway are not sufficient to specify
271the route (as in the
272.Tn ISO
273case where several interfaces may have the
274same address), the
275.Fl ifp
276or
277.Fl ifa
278modifiers may be used to determine the interface or interface address.
279.Pp
280All symbolic names specified for a
281.Ar destination
282or
283.Ar gateway
284are looked up first as a host name using
285.Xr gethostbyname 3 .
286If this lookup fails,
287.Xr getnetbyname 3
288is then used to interpret the name as that of a network.
289.Pp
290.Nm Route
291uses a routing socket and the new message types
292RTM_ADD,
293RTM_DELETE,
294RTM_GET,
295and
296RTM_CHANGE.
297As such, only the super-user may modify
298the routing tables.
299.Sh DIAGNOSTICS
300.Bl -tag -width Ds
301.It Sy "add [host \&| network ] %s: gateway %s flags %x"
302The specified route is being added to the tables.  The
303values printed are from the routing table entry supplied
304in the
305.Xr ioctl 2
306call.
307If the gateway address used was not the primary address of the gateway
308(the first one returned by
309.Xr gethostbyname 3 ) ,
310the gateway address is printed numerically as well as symbolically.
311.It Sy "delete [ host \&| network ] %s: gateway %s flags %x"
312As above, but when deleting an entry.
313.It Sy "%s %s done"
314When the
315.Cm flush
316command is specified, each routing table entry deleted
317is indicated with a message of this form.
318.It Sy "Network is unreachable"
319An attempt to add a route failed because the gateway listed was not
320on a directly-connected network.
321The next-hop gateway must be given.
322.It Sy "not in table"
323A delete operation was attempted for an entry which
324wasn't present in the tables.
325.It Sy "routing table overflow"
326An add operation was attempted, but the system was
327low on resources and was unable to allocate memory
328to create the new entry.
329.El
330.Sh SEE ALSO
331.Xr netintro 4 ,
332.Xr route 4 ,
333.Xr IPXrouted 8 ,
334.Xr routed 8
335.\" .Xr XNSrouted 8
336.\" Xr esis 4 ,
337.Sh HISTORY
338The
339.Nm
340command appeared in
341.Bx 4.2 .
342.Sh BUGS
343The first paragraph may have slightly exaggerated
344.Xr routed 8 Ns 's
345abilities.
346