xref: /f-stack/tools/route/route.8 (revision 22ce4aff)
1144c6bcdSlogwang.\" Copyright (c) 1983, 1991, 1993
2144c6bcdSlogwang.\"	The Regents of the University of California.  All rights reserved.
3144c6bcdSlogwang.\"
4144c6bcdSlogwang.\" Redistribution and use in source and binary forms, with or without
5144c6bcdSlogwang.\" modification, are permitted provided that the following conditions
6144c6bcdSlogwang.\" are met:
7144c6bcdSlogwang.\" 1. Redistributions of source code must retain the above copyright
8144c6bcdSlogwang.\"    notice, this list of conditions and the following disclaimer.
9144c6bcdSlogwang.\" 2. Redistributions in binary form must reproduce the above copyright
10144c6bcdSlogwang.\"    notice, this list of conditions and the following disclaimer in the
11144c6bcdSlogwang.\"    documentation and/or other materials provided with the distribution.
12*22ce4affSfengbojiang.\" 3. Neither the name of the University nor the names of its contributors
13144c6bcdSlogwang.\"    may be used to endorse or promote products derived from this software
14144c6bcdSlogwang.\"    without specific prior written permission.
15144c6bcdSlogwang.\"
16144c6bcdSlogwang.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17144c6bcdSlogwang.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18144c6bcdSlogwang.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19144c6bcdSlogwang.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20144c6bcdSlogwang.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21144c6bcdSlogwang.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22144c6bcdSlogwang.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23144c6bcdSlogwang.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24144c6bcdSlogwang.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25144c6bcdSlogwang.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26144c6bcdSlogwang.\" SUCH DAMAGE.
27144c6bcdSlogwang.\"
28144c6bcdSlogwang.\"     @(#)route.8	8.3 (Berkeley) 3/19/94
29144c6bcdSlogwang.\" $FreeBSD$
30144c6bcdSlogwang.\"
31*22ce4affSfengbojiang.Dd January 9, 2019
32144c6bcdSlogwang.Dt ROUTE 8
33144c6bcdSlogwang.Os
34144c6bcdSlogwang.Sh NAME
35144c6bcdSlogwang.Nm route
36144c6bcdSlogwang.Nd manually manipulate the routing tables
37144c6bcdSlogwang.Sh SYNOPSIS
38144c6bcdSlogwang.Nm
39144c6bcdSlogwang.Op Fl dnqtv
40144c6bcdSlogwang.Ar command
41144c6bcdSlogwang.Oo
42144c6bcdSlogwang.Op Ar modifiers
43144c6bcdSlogwang.Ar args
44144c6bcdSlogwang.Oc
45144c6bcdSlogwang.Sh DESCRIPTION
46144c6bcdSlogwangThe
47144c6bcdSlogwang.Nm
48144c6bcdSlogwangutility is used to manually manipulate the network
49144c6bcdSlogwangrouting tables.
50144c6bcdSlogwangIt normally is not needed, as a
51144c6bcdSlogwangsystem routing table management daemon, such as
52144c6bcdSlogwang.Xr routed 8 ,
53144c6bcdSlogwangshould tend to this task.
54144c6bcdSlogwang.Pp
55144c6bcdSlogwangThe
56144c6bcdSlogwang.Nm
57144c6bcdSlogwangutility supports a limited number of general options,
58144c6bcdSlogwangbut a rich command language, enabling the user to specify
59144c6bcdSlogwangany arbitrary request that could be delivered via the
60144c6bcdSlogwangprogrammatic interface discussed in
61144c6bcdSlogwang.Xr route 4 .
62144c6bcdSlogwang.Pp
63144c6bcdSlogwangThe following options are available:
64144c6bcdSlogwang.Bl -tag -width indent
65144c6bcdSlogwang.It Fl 4
66144c6bcdSlogwangSpecify
67144c6bcdSlogwang.Cm inet
68144c6bcdSlogwangaddress family as family hint for subcommands.
69144c6bcdSlogwang.It Fl 6
70144c6bcdSlogwangSpecify
71*22ce4affSfengbojiang.Cm inet6
72144c6bcdSlogwangaddress family as family hint for subcommands.
73144c6bcdSlogwang.It Fl d
74144c6bcdSlogwangRun in debug-only mode, i.e., do not actually modify the routing table.
75144c6bcdSlogwang.It Fl n
76144c6bcdSlogwangBypass attempts to print host and network names symbolically
77144c6bcdSlogwangwhen reporting actions.
78144c6bcdSlogwang(The process of translating between symbolic
79144c6bcdSlogwangnames and numerical equivalents can be quite time consuming, and
80144c6bcdSlogwangmay require correct operation of the network; thus it may be expedient
81144c6bcdSlogwangto forget this, especially when attempting to repair networking operations).
82144c6bcdSlogwang.It Fl t
83144c6bcdSlogwangRun in test-only mode.
84144c6bcdSlogwang.Pa /dev/null
85144c6bcdSlogwangis used instead of a socket.
86144c6bcdSlogwang.It Fl v
87144c6bcdSlogwang(verbose) Print additional details.
88144c6bcdSlogwang.It Fl q
89144c6bcdSlogwangSuppress all output from the
90144c6bcdSlogwang.Cm add , change , delete ,
91144c6bcdSlogwangand
92144c6bcdSlogwang.Cm flush
93144c6bcdSlogwangcommands.
94144c6bcdSlogwang.El
95144c6bcdSlogwang.Pp
96144c6bcdSlogwangThe
97144c6bcdSlogwang.Nm
98144c6bcdSlogwangutility provides the following commands:
99144c6bcdSlogwang.Pp
100144c6bcdSlogwang.Bl -tag -width Fl -compact
101144c6bcdSlogwang.It Cm add
102144c6bcdSlogwangAdd a route.
103144c6bcdSlogwang.It Cm flush
104144c6bcdSlogwangRemove all routes.
105144c6bcdSlogwang.It Cm delete
106144c6bcdSlogwangDelete a specific route.
107144c6bcdSlogwang.It Cm del
108144c6bcdSlogwangAnother name for the
109144c6bcdSlogwang.Cm delete
110144c6bcdSlogwangcommand.
111144c6bcdSlogwang.It Cm change
112144c6bcdSlogwangChange aspects of a route (such as its gateway).
113144c6bcdSlogwang.It Cm get
114144c6bcdSlogwangLookup and display the route for a destination.
115144c6bcdSlogwang.It Cm monitor
116144c6bcdSlogwangContinuously report any changes to the routing information base,
117144c6bcdSlogwangrouting lookup misses, or suspected network partitionings.
118144c6bcdSlogwang.It Cm show
119144c6bcdSlogwangAnother name for the
120144c6bcdSlogwang.Cm get
121144c6bcdSlogwangcommand.
122144c6bcdSlogwang.El
123144c6bcdSlogwang.Pp
124144c6bcdSlogwangThe monitor command has the syntax:
125144c6bcdSlogwang.Pp
126144c6bcdSlogwang.Bd -ragged -offset indent -compact
127144c6bcdSlogwang.Nm
128144c6bcdSlogwang.Op Fl n
129144c6bcdSlogwang.Cm monitor Op Fl fib Ar number
130144c6bcdSlogwang.Ed
131144c6bcdSlogwang.Pp
132144c6bcdSlogwangThe flush command has the syntax:
133144c6bcdSlogwang.Pp
134144c6bcdSlogwang.Bd -ragged -offset indent -compact
135144c6bcdSlogwang.Nm
136*22ce4affSfengbojiang.Op Fl n
137*22ce4affSfengbojiang.Cm flush Oc Oo Ar family Oc Op Fl fib Ar number
138144c6bcdSlogwang.Ed
139144c6bcdSlogwang.Pp
140144c6bcdSlogwangIf the
141144c6bcdSlogwang.Cm flush
142144c6bcdSlogwangcommand is specified,
143144c6bcdSlogwang.Nm
144144c6bcdSlogwangwill ``flush'' the routing tables of all gateway entries.
145144c6bcdSlogwangWhen the address family may is specified by any of the
146144c6bcdSlogwang.Fl osi ,
147144c6bcdSlogwang.Fl xns ,
148144c6bcdSlogwang.Fl inet6 ,
149144c6bcdSlogwangor
150144c6bcdSlogwang.Fl inet
151144c6bcdSlogwangmodifiers, only routes having destinations with addresses in the
152144c6bcdSlogwangdelineated family will be deleted.
153144c6bcdSlogwangAdditionally,
154144c6bcdSlogwang.Fl 4
155144c6bcdSlogwangor
156144c6bcdSlogwang.Fl 6
157144c6bcdSlogwangcan be used as aliases for
158144c6bcdSlogwang.Fl inet
159144c6bcdSlogwangand
160144c6bcdSlogwang.Fl inet6
161144c6bcdSlogwangmodifiers.
162144c6bcdSlogwangWhen a
163144c6bcdSlogwang.Fl fib
164144c6bcdSlogwangoption is specified, the operation will be applied to
165144c6bcdSlogwangthe specified FIB
166144c6bcdSlogwang.Pq routing table .
167144c6bcdSlogwang.Pp
168*22ce4affSfengbojiangThe add command has the following syntax:
169*22ce4affSfengbojiang.Pp
170*22ce4affSfengbojiang.Bd -ragged -offset indent -compact
171*22ce4affSfengbojiang.Nm
172*22ce4affSfengbojiang.Op Fl n
173*22ce4affSfengbojiang.Cm add
174*22ce4affSfengbojiang.Op Fl net No \&| Fl host
175*22ce4affSfengbojiang.Ar destination gateway
176*22ce4affSfengbojiang.Op Ar netmask
177*22ce4affSfengbojiang.Op Fl fib Ar number
178*22ce4affSfengbojiang.Ed
179*22ce4affSfengbojiang.Pp
180*22ce4affSfengbojiangand the other commands have the following syntax:
181144c6bcdSlogwang.Pp
182144c6bcdSlogwang.Bd -ragged -offset indent -compact
183144c6bcdSlogwang.Nm
184144c6bcdSlogwang.Op Fl n
185144c6bcdSlogwang.Ar command
186144c6bcdSlogwang.Op Fl net No \&| Fl host
187*22ce4affSfengbojiang.Ar destination
188*22ce4affSfengbojiang.Op Ar gateway Op Ar netmask
189144c6bcdSlogwang.Op Fl fib Ar number
190144c6bcdSlogwang.Ed
191144c6bcdSlogwang.Pp
192144c6bcdSlogwangwhere
193144c6bcdSlogwang.Ar destination
194144c6bcdSlogwangis the destination host or network,
195144c6bcdSlogwang.Ar gateway
196144c6bcdSlogwangis the next-hop intermediary via which packets should be routed.
197144c6bcdSlogwangRoutes to a particular host may be distinguished from those to
198144c6bcdSlogwanga network by interpreting the Internet address specified as the
199144c6bcdSlogwang.Ar destination
200144c6bcdSlogwangargument.
201144c6bcdSlogwangThe optional modifiers
202144c6bcdSlogwang.Fl net
203144c6bcdSlogwangand
204144c6bcdSlogwang.Fl host
205144c6bcdSlogwangforce the destination to be interpreted as a network or a host, respectively.
206144c6bcdSlogwangOtherwise, if the
207144c6bcdSlogwang.Ar destination
208144c6bcdSlogwanghas a
209144c6bcdSlogwang.Dq local address part
210144c6bcdSlogwangof
211144c6bcdSlogwangINADDR_ANY
212144c6bcdSlogwang.Pq Li 0.0.0.0 ,
213144c6bcdSlogwangor if the
214144c6bcdSlogwang.Ar destination
215144c6bcdSlogwangis the symbolic name of a network, then the route is
216144c6bcdSlogwangassumed to be to a network; otherwise, it is presumed to be a
217144c6bcdSlogwangroute to a host.
218144c6bcdSlogwangOptionally, the
219144c6bcdSlogwang.Ar destination
220144c6bcdSlogwangcould also be specified in the
221144c6bcdSlogwang.Ar net Ns / Ns Ar bits
222144c6bcdSlogwangformat.
223144c6bcdSlogwang.Pp
224144c6bcdSlogwangFor example,
225144c6bcdSlogwang.Li 128.32
226144c6bcdSlogwangis interpreted as
227144c6bcdSlogwang.Fl host Li 128.0.0.32 ;
228144c6bcdSlogwang.Li 128.32.130
229144c6bcdSlogwangis interpreted as
230144c6bcdSlogwang.Fl host Li 128.32.0.130 ;
231144c6bcdSlogwang.Fl net Li 128.32
232144c6bcdSlogwangis interpreted as
233144c6bcdSlogwang.Li 128.32.0.0;
234144c6bcdSlogwang.Fl net Li 128.32.130
235144c6bcdSlogwangis interpreted as
236144c6bcdSlogwang.Li 128.32.130.0;
237144c6bcdSlogwangand
238144c6bcdSlogwang.Li 192.168.64/20
239144c6bcdSlogwangis interpreted as
240144c6bcdSlogwang.Fl net Li 192.168.64 Fl netmask Li 255.255.240.0 .
241144c6bcdSlogwang.Pp
242144c6bcdSlogwangA
243144c6bcdSlogwang.Ar destination
244144c6bcdSlogwangof
245144c6bcdSlogwang.Ar default
246144c6bcdSlogwangis a synonym for the default route.
247144c6bcdSlogwangFor
248144c6bcdSlogwang.Li IPv4
249144c6bcdSlogwangit is
250144c6bcdSlogwang.Fl net Fl inet Li 0.0.0.0 ,
251144c6bcdSlogwangand for
252144c6bcdSlogwang.Li IPv6
253144c6bcdSlogwangit is
254144c6bcdSlogwang.Fl net Fl inet6 Li :: .
255144c6bcdSlogwang.Pp
256144c6bcdSlogwangIf the destination is directly reachable
257144c6bcdSlogwangvia an interface requiring
258144c6bcdSlogwangno intermediary system to act as a gateway, the
259144c6bcdSlogwang.Fl interface
260144c6bcdSlogwangmodifier should be specified;
261144c6bcdSlogwangthe gateway given is the address of this host on the common network,
262144c6bcdSlogwangindicating the interface to be used for transmission.
263144c6bcdSlogwangAlternately, if the interface is point to point the name of the interface
264144c6bcdSlogwangitself may be given, in which case the route remains valid even
265144c6bcdSlogwangif the local or remote addresses change.
266144c6bcdSlogwang.Pp
267144c6bcdSlogwangThe optional modifiers
268144c6bcdSlogwang.Fl xns ,
269144c6bcdSlogwang.Fl osi ,
270144c6bcdSlogwangand
271144c6bcdSlogwang.Fl link
272144c6bcdSlogwangspecify that all subsequent addresses are in the
273144c6bcdSlogwang.Tn XNS
274144c6bcdSlogwangor
275144c6bcdSlogwang.Tn OSI
276144c6bcdSlogwangaddress families,
277144c6bcdSlogwangor are specified as link-level addresses,
278144c6bcdSlogwangand the names must be numeric specifications rather than
279144c6bcdSlogwangsymbolic names.
280144c6bcdSlogwang.Pp
281144c6bcdSlogwangThe optional
282144c6bcdSlogwang.Fl netmask
283144c6bcdSlogwangmodifier is intended
284144c6bcdSlogwangto achieve the effect of an
285144c6bcdSlogwang.Tn OSI
286144c6bcdSlogwang.Tn ESIS
287144c6bcdSlogwangredirect with the netmask option,
288144c6bcdSlogwangor to manually add subnet routes with
289144c6bcdSlogwangnetmasks different from that of the implied network interface
290144c6bcdSlogwang(as would otherwise be communicated using the OSPF or ISIS routing protocols).
291144c6bcdSlogwangOne specifies an additional ensuing address parameter
292144c6bcdSlogwang(to be interpreted as a network mask).
293144c6bcdSlogwangThe implicit network mask generated in the AF_INET case
294144c6bcdSlogwangcan be overridden by making sure this option follows the destination parameter.
295144c6bcdSlogwang.Pp
296144c6bcdSlogwangFor
297144c6bcdSlogwang.Dv AF_INET6 ,
298144c6bcdSlogwangthe
299144c6bcdSlogwang.Fl prefixlen
300144c6bcdSlogwangqualifier
301144c6bcdSlogwangis available instead of the
302144c6bcdSlogwang.Fl mask
303144c6bcdSlogwangqualifier because non-continuous masks are not allowed in IPv6.
304144c6bcdSlogwangFor example,
305144c6bcdSlogwang.Fl prefixlen Li 32
306*22ce4affSfengbojiangspecifies that a network mask of
307144c6bcdSlogwang.Li ffff:ffff:0000:0000:0000:0000:0000:0000
308*22ce4affSfengbojiangwill be used.
309*22ce4affSfengbojiangThe default prefixlen is 64.
310*22ce4affSfengbojiangHowever, it is assumed to be 0 if
311144c6bcdSlogwang.Cm default
312*22ce4affSfengbojiangis specified for
313*22ce4affSfengbojiang.Ar destination .
314144c6bcdSlogwangNote that the qualifier works only for
315144c6bcdSlogwang.Dv AF_INET6
316144c6bcdSlogwangaddress family.
317144c6bcdSlogwang.Pp
318144c6bcdSlogwangRoutes have associated flags which influence operation of the protocols
319144c6bcdSlogwangwhen sending to destinations matched by the routes.
320144c6bcdSlogwangThese flags may be set (or sometimes cleared)
321144c6bcdSlogwangby indicating the following corresponding modifiers:
322144c6bcdSlogwang.Bd -literal
323144c6bcdSlogwang-xresolve  RTF_XRESOLVE   - emit mesg on use (for external lookup)
324144c6bcdSlogwang-iface    ~RTF_GATEWAY    - destination is directly reachable
325144c6bcdSlogwang-static    RTF_STATIC     - manually added route
326144c6bcdSlogwang-nostatic ~RTF_STATIC     - pretend route added by kernel or daemon
327144c6bcdSlogwang-reject    RTF_REJECT     - emit an ICMP unreachable when matched
328144c6bcdSlogwang-blackhole RTF_BLACKHOLE  - silently discard pkts (during updates)
329144c6bcdSlogwang-proto1    RTF_PROTO1     - set protocol specific routing flag #1
330144c6bcdSlogwang-proto2    RTF_PROTO2     - set protocol specific routing flag #2
331144c6bcdSlogwang.Ed
332144c6bcdSlogwang.Pp
333144c6bcdSlogwangThe optional modifiers
334144c6bcdSlogwang.Fl rtt ,
335144c6bcdSlogwang.Fl rttvar ,
336144c6bcdSlogwang.Fl sendpipe ,
337144c6bcdSlogwang.Fl recvpipe ,
338144c6bcdSlogwang.Fl mtu ,
339144c6bcdSlogwang.Fl hopcount ,
340144c6bcdSlogwang.Fl expire ,
341144c6bcdSlogwangand
342144c6bcdSlogwang.Fl ssthresh
343144c6bcdSlogwangprovide initial values to quantities maintained in the routing entry
344144c6bcdSlogwangby transport level protocols, such as TCP or TP4.
345144c6bcdSlogwangThese may be individually locked by preceding each such modifier to
346144c6bcdSlogwangbe locked by
347144c6bcdSlogwangthe
348144c6bcdSlogwang.Fl lock
349144c6bcdSlogwangmeta-modifier, or one can
350144c6bcdSlogwangspecify that all ensuing metrics may be locked by the
351144c6bcdSlogwang.Fl lockrest
352144c6bcdSlogwangmeta-modifier.
353144c6bcdSlogwang.Pp
354144c6bcdSlogwangNote that
355144c6bcdSlogwang.Fl expire
356144c6bcdSlogwangaccepts expiration time of the route as the number of seconds since the
357144c6bcdSlogwangEpoch
358144c6bcdSlogwang.Pq see Xr time 3 .
359144c6bcdSlogwangWhen the first character of the number is
360144c6bcdSlogwang.Dq +
361144c6bcdSlogwangor
362144c6bcdSlogwang.Dq - ,
363144c6bcdSlogwangit is interpreted as a value relative to the current time.
364144c6bcdSlogwang.Pp
365144c6bcdSlogwangThe optional modifier
366144c6bcdSlogwang.Fl fib Ar number
367144c6bcdSlogwangspecifies that the command will be applied to a non-default FIB.
368144c6bcdSlogwangThe
369144c6bcdSlogwang.Ar number
370144c6bcdSlogwangmust be smaller than the
371144c6bcdSlogwang.Va net.fibs
372144c6bcdSlogwang.Xr sysctl 8
373144c6bcdSlogwangMIB.
374144c6bcdSlogwangWhen this modifier is not specified,
375144c6bcdSlogwangor a negative number is specified,
376144c6bcdSlogwangthe default FIB shown in the
377144c6bcdSlogwang.Va net.my_fibnum
378144c6bcdSlogwang.Xr sysctl 8
379144c6bcdSlogwangMIB will be used.
380144c6bcdSlogwang.Pp
381144c6bcdSlogwangThe
382144c6bcdSlogwang.Ar number
383144c6bcdSlogwangallows multiple FIBs by a comma-separeted list and/or range
384144c6bcdSlogwangspecification.
385144c6bcdSlogwangThe
386144c6bcdSlogwang.Qq Fl fib Li 2,4,6
387144c6bcdSlogwangmeans the FIB number 2, 4, and 6.
388144c6bcdSlogwangThe
389144c6bcdSlogwang.Qq Fl fib Li 1,3-5,6
390144c6bcdSlogwangmeans the 1, 3, 4, 5, and 6.
391144c6bcdSlogwang.Pp
392144c6bcdSlogwangIn a
393144c6bcdSlogwang.Cm change
394144c6bcdSlogwangor
395144c6bcdSlogwang.Cm add
396144c6bcdSlogwangcommand where the destination and gateway are not sufficient to specify
397144c6bcdSlogwangthe route (as in the
398144c6bcdSlogwang.Tn ISO
399144c6bcdSlogwangcase where several interfaces may have the
400144c6bcdSlogwangsame address), the
401144c6bcdSlogwang.Fl ifp
402144c6bcdSlogwangor
403144c6bcdSlogwang.Fl ifa
404144c6bcdSlogwangmodifiers may be used to determine the interface or interface address.
405144c6bcdSlogwang.Pp
406144c6bcdSlogwangAll symbolic names specified for a
407144c6bcdSlogwang.Ar destination
408144c6bcdSlogwangor
409144c6bcdSlogwang.Ar gateway
410144c6bcdSlogwangare looked up first as a host name using
411144c6bcdSlogwang.Xr gethostbyname 3 .
412144c6bcdSlogwangIf this lookup fails,
413144c6bcdSlogwang.Xr getnetbyname 3
414144c6bcdSlogwangis then used to interpret the name as that of a network.
415144c6bcdSlogwang.Pp
416144c6bcdSlogwangThe
417144c6bcdSlogwang.Nm
418144c6bcdSlogwangutility uses a routing socket and the new message types
419144c6bcdSlogwang.Dv RTM_ADD , RTM_DELETE , RTM_GET ,
420144c6bcdSlogwangand
421144c6bcdSlogwang.Dv RTM_CHANGE .
422144c6bcdSlogwangAs such, only the super-user may modify
423144c6bcdSlogwangthe routing tables.
424144c6bcdSlogwang.Sh EXIT STATUS
425144c6bcdSlogwang.Ex -std
426144c6bcdSlogwang.Sh EXAMPLES
427144c6bcdSlogwangAdd a default route to the network routing table.
428144c6bcdSlogwangThis will send all packets for destinations not available in the routing table
429144c6bcdSlogwangto the default gateway at 192.168.1.1:
430144c6bcdSlogwang.Pp
431144c6bcdSlogwang.Dl route add -net 0.0.0.0/0 192.168.1.1
432144c6bcdSlogwang.Pp
433144c6bcdSlogwangA shorter version of adding a default route can also be written as:
434144c6bcdSlogwang.Pp
435144c6bcdSlogwang.Dl route add default 192.168.1.1
436144c6bcdSlogwang.Pp
437144c6bcdSlogwangAdd a static route to the 172.16.10.0/24 network via the 172.16.1.1 gateway:
438144c6bcdSlogwang.Pp
439144c6bcdSlogwang.Dl route add -net 172.16.10.0/24 172.16.1.1
440144c6bcdSlogwang.Pp
441144c6bcdSlogwangChange the gateway of an already established static route in the routing table:
442144c6bcdSlogwang.Pp
443144c6bcdSlogwang.Dl route change -net 172.16.10.0/24 172.16.1.2
444144c6bcdSlogwang.Pp
445144c6bcdSlogwangDisplay the route for a destination network:
446144c6bcdSlogwang.Pp
447144c6bcdSlogwang.Dl route show 172.16.10.0
448144c6bcdSlogwang.Pp
449144c6bcdSlogwangDelete a static route from the routing table:
450144c6bcdSlogwang.Pp
451144c6bcdSlogwang.Dl route delete -net 172.16.10.0/24 172.16.1.2
452144c6bcdSlogwang.Pp
453144c6bcdSlogwangRemove all routes from the routing table:
454144c6bcdSlogwang.Pp
455144c6bcdSlogwang.Dl route flush
456144c6bcdSlogwang.Sh DIAGNOSTICS
457144c6bcdSlogwang.Bl -diag
458144c6bcdSlogwang.It "add [host \&| network ] %s: gateway %s flags %x"
459144c6bcdSlogwangThe specified route is being added to the tables.
460144c6bcdSlogwangThe
461144c6bcdSlogwangvalues printed are from the routing table entry supplied
462144c6bcdSlogwangin the
463144c6bcdSlogwang.Xr ioctl 2
464144c6bcdSlogwangcall.
465144c6bcdSlogwangIf the gateway address used was not the primary address of the gateway
466144c6bcdSlogwang(the first one returned by
467144c6bcdSlogwang.Xr gethostbyname 3 ) ,
468144c6bcdSlogwangthe gateway address is printed numerically as well as symbolically.
469144c6bcdSlogwang.It "delete [ host \&| network ] %s: gateway %s flags %x"
470144c6bcdSlogwangAs above, but when deleting an entry.
471144c6bcdSlogwang.It "%s %s done"
472144c6bcdSlogwangWhen the
473144c6bcdSlogwang.Cm flush
474144c6bcdSlogwangcommand is specified, each routing table entry deleted
475144c6bcdSlogwangis indicated with a message of this form.
476144c6bcdSlogwang.It "Network is unreachable"
477144c6bcdSlogwangAn attempt to add a route failed because the gateway listed was not
478144c6bcdSlogwangon a directly-connected network.
479144c6bcdSlogwangThe next-hop gateway must be given.
480144c6bcdSlogwang.It "not in table"
481144c6bcdSlogwangA delete operation was attempted for an entry which
482144c6bcdSlogwangwas not present in the tables.
483144c6bcdSlogwang.It "routing table overflow"
484144c6bcdSlogwangAn add operation was attempted, but the system was
485144c6bcdSlogwanglow on resources and was unable to allocate memory
486144c6bcdSlogwangto create the new entry.
487144c6bcdSlogwang.It "gateway uses the same route"
488144c6bcdSlogwangA
489144c6bcdSlogwang.Cm change
490144c6bcdSlogwangoperation resulted in a route whose gateway uses the
491144c6bcdSlogwangsame route as the one being changed.
492144c6bcdSlogwangThe next-hop gateway should be reachable through a different route.
493144c6bcdSlogwang.El
494144c6bcdSlogwang.Sh SEE ALSO
495144c6bcdSlogwang.\".Xr esis 4 ,
496144c6bcdSlogwang.Xr netintro 4 ,
497144c6bcdSlogwang.Xr route 4 ,
498144c6bcdSlogwang.Xr arp 8 ,
499144c6bcdSlogwang.Xr routed 8
500144c6bcdSlogwang.\".Xr XNSrouted 8
501144c6bcdSlogwang.Sh HISTORY
502144c6bcdSlogwangThe
503144c6bcdSlogwang.Nm
504144c6bcdSlogwangutility appeared in
505144c6bcdSlogwang.Bx 4.2 .
506144c6bcdSlogwang.Sh BUGS
507144c6bcdSlogwangThe first paragraph may have slightly exaggerated
508144c6bcdSlogwang.Xr routed 8 Ns 's
509144c6bcdSlogwangabilities.
510144c6bcdSlogwang.Pp
511144c6bcdSlogwangCurrently, routes with the
512144c6bcdSlogwang.Dv RTF_BLACKHOLE
513144c6bcdSlogwangflag set need to have the gateway set to an instance of the
514144c6bcdSlogwang.Xr lo 4
515144c6bcdSlogwangdriver, using the
516144c6bcdSlogwang.Fl iface
517144c6bcdSlogwangoption, for the flag to have any effect; unless IP fast forwarding
518144c6bcdSlogwangis enabled, in which case the meaning of the flag will always
519144c6bcdSlogwangbe honored.
520