1 .\" $NetBSD: route.8,v 1.39 2006/08/06 21:47:35 dyoung Exp $
3 .\" Copyright (c) 1983, 1991, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the University nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" @(#)route.8 8.4 (Berkeley) 6/1/94
37 .Nd manually manipulate the routing tables
48 is a utility used to manually manipulate the network
50 Except for setting up the default route, it is normally not needed,
51 as a system routing table management daemon such as
53 should tend to this task.
56 can be used to modify nearly any aspect of the routing policy,
57 except packet forwarding, which can be manipulated through the
63 utility supports a limited number of general options,
64 but a rich command language, enabling the user to specify
65 any arbitrary request that could be delivered via the
66 programmatic interface discussed in
71 Remove all routes (as per
73 If used in conjunction with the
81 removes the routes before performing the command.
83 Bypasses attempts to print host and network names symbolically
84 when reporting actions.
85 (The process of translating between symbolic
86 names and numerical equivalents can be quite time consuming, and
87 may require correct operation of the network; thus it may be expedient
88 to forgo this, especially when attempting to repair networking operations).
90 Suppress all output from commands that manipulate the routing table.
92 Print a space when a flag is missing so that flags are vertically aligned
93 instead of printing the flags that are set as a contiguous string.
95 (short) Suppresses all output from a
97 command except for the actual gateway that will be used.
98 How the gateway is printed depends on the type of route being looked up.
100 (verbose) Print additional details.
105 utility provides several commands:
107 .Bl -tag -width Fl -compact
113 Remove all routes including the default gateway.
115 Delete a specific route.
117 Change aspects of a route (such as its gateway).
119 Lookup and display the route for a destination.
121 Print out the route table similar to "netstat \-r" (see
124 Continuously report any changes to the routing information base,
125 routing lookup misses, or suspected network partitionings.
128 The monitor command has the syntax
130 .Bd -filled -offset indent -compact
136 The flush command has the syntax
138 .Bd -filled -offset indent -compact
147 command is specified,
149 will ``flush'' the routing tables of all gateway entries.
150 When the address family is specified by any of the
157 modifiers, only routes having destinations with addresses in the
158 delineated family will be manipulated.
160 The other commands have the following syntax:
162 .Bd -filled -offset indent -compact
166 .Op Fl net No \&| Fl host
167 .Ar destination gateway
172 is the destination host or network, and
174 is the next-hop intermediary via which packets should be routed.
175 Routes to a particular host may be distinguished from those to
176 a network by interpreting the Internet address specified as the
179 The optional modifiers
183 force the destination to be interpreted as a network or a host, respectively.
186 has a ``local address part'' of
190 is the symbolic name of a network, then the route is
191 assumed to be to a network; otherwise, it is presumed to be a
195 can also be specified in the
196 .Ar net Ns / Ns Ar bits
202 .Fl host Li 128.0.0.32 ;
205 .Fl host Li 128.32.0.130 ;
210 .Fl net Li 128.32.130
218 to set up a default route to a smart
220 If no other routes match, this default route will be used as a last resort.
222 If the destination is directly reachable
223 via an interface requiring
224 no intermediary system to act as a gateway, the
226 modifier should be specified;
227 the gateway given is the address of this host on the common network,
228 indicating the interface to be used for transmission.
230 The optional modifiers
236 specify that all subsequent addresses are in the
242 or are specified as link-level addresses,
243 and the names must be numeric specifications rather than
248 qualifier is intended
249 to achieve the effect of an
252 redirect with the netmask option,
253 or to manually add subnet routes with
254 netmasks different from that of the implied network interface
255 (as would otherwise be communicated using the OSPF or ISIS routing protocols).
256 One specifies an additional ensuing address parameter
257 (to be interpreted as a network mask).
258 The implicit network mask generated in the
261 can be overridden by making sure this option follows the destination parameter.
263 is also available for similar purpose, in IPv4 and IPv6 case.
265 Routes have associated flags which influence operation of the protocols
266 when sending to destinations matched by the routes.
267 These flags may be set (or sometimes cleared)
268 by indicating the following corresponding modifiers:
270 -cloning RTF_CLONING - generates a new route on use
271 -nocloning ~RTF_CLONING - stop generating new routes on use
272 -cloned RTF_CLONED - cloned route generated by RTF_CLONING
273 -nocloned ~RTF_CLONED - prevent removal with RTF_CLONING parent
274 -xresolve RTF_XRESOLVE - emit mesg on use (for external lookup)
275 -iface ~RTF_GATEWAY - destination is directly reachable
276 -static RTF_STATIC - manually added route
277 -nostatic ~RTF_STATIC - pretend route added by kernel or daemon
278 -reject RTF_REJECT - emit an ICMP unreachable when matched
279 -blackhole RTF_BLACKHOLE - silently discard pkts (during updates)
280 -proto1 RTF_PROTO1 - set protocol specific routing flag #1
281 -proto2 RTF_PROTO2 - set protocol specific routing flag #2
282 -llinfo RTF_LLINFO - validly translates proto addr to link addr
285 The optional modifiers
295 provide initial values to quantities maintained in the routing entry
296 by transport level protocols, such as TCP or TP4.
297 These may be individually locked by preceding each such modifier to
301 meta-modifier, or one can
302 specify that all ensuing metrics may be locked by the
310 command where the destination and gateway are not sufficient to specify
313 case where several interfaces may have the
318 modifiers may be used to determine the interface or interface address.
320 All symbolic names specified for a
324 are looked up first as a host name using
325 .Xr gethostbyname 3 .
326 If this lookup fails,
328 is then used to interpret the name as that of a network.
331 uses a routing socket and the new message types
337 As such, only the super-user may modify
342 utility exits 0 on success, and \*[Gt]0 if an error occurs.
343 This includes the use of the
345 command to look up a route that is incomplete.
347 This sets the default route to 192.168.0.1:
348 .Dl route add default 192.168.0.1
349 This shows all routes, without DNS resolution (this is useful if the
350 DNS is not available):
352 To install a static route through 10.200.0.1 to reach the network
353 192.168.1.0/28, use this:
354 .Dl route add -net 192.168.1.0 -netmask 255.255.255.240 10.200.0.1
357 .It Sy "add [host \&| network ] %s: gateway %s flags %x"
358 The specified route is being added to the tables.
359 The values printed are from the routing table entry supplied in the
362 If the gateway address used was not the primary address of the gateway
363 (the first one returned by
364 .Xr gethostbyname 3 ) ,
365 the gateway address is printed numerically as well as symbolically.
366 .It Sy "delete [ host \&| network ] %s: gateway %s flags %x"
367 As above, but when deleting an entry.
371 command is specified, each routing table entry deleted
372 is indicated with a message of this form.
373 .It Sy "Network is unreachable"
374 An attempt to add a route failed because the gateway listed was not
375 on a directly-connected network.
376 The next-hop gateway must be given.
377 .It Sy "not in table"
378 A delete operation was attempted for an entry which
379 wasn't present in the tables.
380 .It Sy "routing table overflow"
381 An add operation was attempted, but the system was
382 low on resources and was unable to allocate memory
383 to create the new entry.
384 .It Sy "Permission denied"
385 The attempted operation is privileged.
386 Only root may modify the routing tables.
387 These privileges are enforced by the kernel.
401 IPv6 support was added by WIDE/KAME project.
403 The first paragraph may have slightly exaggerated
411 modifiers with the add command will incorrectly fail with a
412 .Dq Network is unreachable
413 message if there is no default route.
417 .Pa sys/net/rtsock.c:route_output