xref: /freebsd/sbin/route/route.8 (revision aa5d3dec9df9379ab610f426e9653d1a55b254e5)
18fae3551SRodney W. Grimes.\" Copyright (c) 1983, 1991, 1993
28fae3551SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
38fae3551SRodney W. Grimes.\"
48fae3551SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
58fae3551SRodney W. Grimes.\" modification, are permitted provided that the following conditions
68fae3551SRodney W. Grimes.\" are met:
78fae3551SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
88fae3551SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
98fae3551SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
108fae3551SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
118fae3551SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
12fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors
138fae3551SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
148fae3551SRodney W. Grimes.\"    without specific prior written permission.
158fae3551SRodney W. Grimes.\"
168fae3551SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
178fae3551SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
188fae3551SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
198fae3551SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
208fae3551SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
218fae3551SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
228fae3551SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
238fae3551SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
248fae3551SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
258fae3551SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
268fae3551SRodney W. Grimes.\" SUCH DAMAGE.
278fae3551SRodney W. Grimes.\"
28*aa5d3decSKristof Provost.Dd November 12, 2024
298fae3551SRodney W. Grimes.Dt ROUTE 8
301d36c899SRuslan Ermilov.Os
318fae3551SRodney W. Grimes.Sh NAME
328fae3551SRodney W. Grimes.Nm route
331cc580efSPhilippe Charnier.Nd manually manipulate the routing tables
348fae3551SRodney W. Grimes.Sh SYNOPSIS
357c7fb079SRuslan Ermilov.Nm
36ab4d1b73SYan Ka, Chiu.Op Fl j Ar jail
371cc580efSPhilippe Charnier.Op Fl dnqtv
388fae3551SRodney W. Grimes.Ar command
398fae3551SRodney W. Grimes.Oo
408fae3551SRodney W. Grimes.Op Ar modifiers
418fae3551SRodney W. Grimes.Ar args
428fae3551SRodney W. Grimes.Oc
438fae3551SRodney W. Grimes.Sh DESCRIPTION
44629e80efSPhilippe CharnierThe
45629e80efSPhilippe Charnier.Nm
46629e80efSPhilippe Charnierutility is used to manually manipulate the network
479806e231SRuslan Ermilovrouting tables.
489806e231SRuslan ErmilovIt normally is not needed, as a
4976a88626SChristian Brueffersystem routing table management daemon, such as
508fae3551SRodney W. Grimes.Xr routed 8 ,
518fae3551SRodney W. Grimesshould tend to this task.
528fae3551SRodney W. Grimes.Pp
538fae3551SRodney W. GrimesThe
541cc580efSPhilippe Charnier.Nm
558fae3551SRodney W. Grimesutility supports a limited number of general options,
568fae3551SRodney W. Grimesbut a rich command language, enabling the user to specify
578fae3551SRodney W. Grimesany arbitrary request that could be delivered via the
588fae3551SRodney W. Grimesprogrammatic interface discussed in
598fae3551SRodney W. Grimes.Xr route 4 .
608fae3551SRodney W. Grimes.Pp
611cc580efSPhilippe CharnierThe following options are available:
621cc580efSPhilippe Charnier.Bl -tag -width indent
6317ed2e8eSAlexander V. Chernikov.It Fl 4
6417ed2e8eSAlexander V. ChernikovSpecify
6517ed2e8eSAlexander V. Chernikov.Cm inet
6617ed2e8eSAlexander V. Chernikovaddress family as family hint for subcommands.
6717ed2e8eSAlexander V. Chernikov.It Fl 6
6817ed2e8eSAlexander V. ChernikovSpecify
6924328efbSKonstantin Belousov.Cm inet6
7017ed2e8eSAlexander V. Chernikovaddress family as family hint for subcommands.
7176a88626SChristian Brueffer.It Fl d
7276a88626SChristian BruefferRun in debug-only mode, i.e., do not actually modify the routing table.
738fae3551SRodney W. Grimes.It Fl n
741cc580efSPhilippe CharnierBypass attempts to print host and network names symbolically
759806e231SRuslan Ermilovwhen reporting actions.
769806e231SRuslan Ermilov(The process of translating between symbolic
778fae3551SRodney W. Grimesnames and numerical equivalents can be quite time consuming, and
788fae3551SRodney W. Grimesmay require correct operation of the network; thus it may be expedient
7932704e57SDaniel Harristo forget this, especially when attempting to repair networking operations).
8031a1fa79SDavid E. O'Brien.It Fl t
8131a1fa79SDavid E. O'BrienRun in test-only mode.
8231a1fa79SDavid E. O'Brien.Pa /dev/null
8331a1fa79SDavid E. O'Brienis used instead of a socket.
848fae3551SRodney W. Grimes.It Fl v
858fae3551SRodney W. Grimes(verbose) Print additional details.
868fae3551SRodney W. Grimes.It Fl q
87999ffea5SRuslan ErmilovSuppress all output from the
88259fcfd3SRuslan Ermilov.Cm add , change , delete ,
89999ffea5SRuslan Ermilovand
90999ffea5SRuslan Ermilov.Cm flush
91999ffea5SRuslan Ermilovcommands.
92ab4d1b73SYan Ka, Chiu.It Fl j Ar jail
93ab4d1b73SYan Ka, ChiuRun inside a jail.
948fae3551SRodney W. Grimes.El
958fae3551SRodney W. Grimes.Pp
968fae3551SRodney W. GrimesThe
971cc580efSPhilippe Charnier.Nm
98064b93d5SAnton Berezinutility provides the following commands:
998fae3551SRodney W. Grimes.Pp
1008fae3551SRodney W. Grimes.Bl -tag -width Fl -compact
1018fae3551SRodney W. Grimes.It Cm add
1028fae3551SRodney W. GrimesAdd a route.
1038fae3551SRodney W. Grimes.It Cm flush
1048fae3551SRodney W. GrimesRemove all routes.
1058fae3551SRodney W. Grimes.It Cm delete
1068fae3551SRodney W. GrimesDelete a specific route.
107064b93d5SAnton Berezin.It Cm del
108064b93d5SAnton BerezinAnother name for the
109064b93d5SAnton Berezin.Cm delete
110064b93d5SAnton Berezincommand.
1118fae3551SRodney W. Grimes.It Cm change
1128fae3551SRodney W. GrimesChange aspects of a route (such as its gateway).
1138fae3551SRodney W. Grimes.It Cm get
1148fae3551SRodney W. GrimesLookup and display the route for a destination.
1158fae3551SRodney W. Grimes.It Cm monitor
1168fae3551SRodney W. GrimesContinuously report any changes to the routing information base,
1178fae3551SRodney W. Grimesrouting lookup misses, or suspected network partitionings.
11846b035ebSJoel Dahl.It Cm show
11946b035ebSJoel DahlAnother name for the
12046b035ebSJoel Dahl.Cm get
12146b035ebSJoel Dahlcommand.
1228fae3551SRodney W. Grimes.El
1238fae3551SRodney W. Grimes.Pp
1241cc580efSPhilippe CharnierThe monitor command has the syntax:
1258fae3551SRodney W. Grimes.Pp
12646eea498SRuslan Ermilov.Bd -ragged -offset indent -compact
1277c7fb079SRuslan Ermilov.Nm
1287c7fb079SRuslan Ermilov.Op Fl n
1299ba63ff5SHiroki Sato.Cm monitor Op Fl fib Ar number
1308fae3551SRodney W. Grimes.Ed
1318fae3551SRodney W. Grimes.Pp
1321cc580efSPhilippe CharnierThe flush command has the syntax:
1338fae3551SRodney W. Grimes.Pp
13446eea498SRuslan Ermilov.Bd -ragged -offset indent -compact
1357c7fb079SRuslan Ermilov.Nm
1369ec35e3cSRyan Stone.Op Fl n
1376dbfbe6eSGordon Bergling.Cm flush Oo Ar family Oc Op Fl fib Ar number
1388fae3551SRodney W. Grimes.Ed
1398fae3551SRodney W. Grimes.Pp
1408fae3551SRodney W. GrimesIf the
1418fae3551SRodney W. Grimes.Cm flush
1428fae3551SRodney W. Grimescommand is specified,
1431cc580efSPhilippe Charnier.Nm
1448fae3551SRodney W. Grimeswill ``flush'' the routing tables of all gateway entries.
1458fae3551SRodney W. GrimesWhen the address family may is specified by any of the
146cfa1ca9dSYoshinobu Inoue.Fl inet6 ,
1478fae3551SRodney W. Grimesor
148120dc21bSAlexander V. Chernikov.Fl inet
1498fae3551SRodney W. Grimesmodifiers, only routes having destinations with addresses in the
150120dc21bSAlexander V. Chernikovdelineated family will be deleted.
151120dc21bSAlexander V. ChernikovAdditionally,
15217ed2e8eSAlexander V. Chernikov.Fl 4
15317ed2e8eSAlexander V. Chernikovor
15417ed2e8eSAlexander V. Chernikov.Fl 6
15517ed2e8eSAlexander V. Chernikovcan be used as aliases for
15617ed2e8eSAlexander V. Chernikov.Fl inet
15717ed2e8eSAlexander V. Chernikovand
15817ed2e8eSAlexander V. Chernikov.Fl inet6
15917ed2e8eSAlexander V. Chernikovmodifiers.
1609ba63ff5SHiroki SatoWhen a
1619ba63ff5SHiroki Sato.Fl fib
1629ba63ff5SHiroki Satooption is specified, the operation will be applied to
1639ba63ff5SHiroki Satothe specified FIB
1649ba63ff5SHiroki Sato.Pq routing table .
1658fae3551SRodney W. Grimes.Pp
166b3b6ff23SRyan StoneThe add command has the following syntax:
167b3b6ff23SRyan Stone.Pp
168b3b6ff23SRyan Stone.Bd -ragged -offset indent -compact
169b3b6ff23SRyan Stone.Nm
170b3b6ff23SRyan Stone.Op Fl n
171b3b6ff23SRyan Stone.Cm add
172b3b6ff23SRyan Stone.Op Fl net No \&| Fl host
173b3b6ff23SRyan Stone.Ar destination gateway
174b3b6ff23SRyan Stone.Op Ar netmask
175b3b6ff23SRyan Stone.Op Fl fib Ar number
176b3b6ff23SRyan Stone.Ed
177b3b6ff23SRyan Stone.Pp
178b3b6ff23SRyan Stoneand the other commands have the following syntax:
1798fae3551SRodney W. Grimes.Pp
18046eea498SRuslan Ermilov.Bd -ragged -offset indent -compact
1817c7fb079SRuslan Ermilov.Nm
1827c7fb079SRuslan Ermilov.Op Fl n
1838fae3551SRodney W. Grimes.Ar command
1848fae3551SRodney W. Grimes.Op Fl net No \&| Fl host
185b3b6ff23SRyan Stone.Ar destination
186b3b6ff23SRyan Stone.Op Ar gateway Op Ar netmask
1879ba63ff5SHiroki Sato.Op Fl fib Ar number
1888fae3551SRodney W. Grimes.Ed
1898fae3551SRodney W. Grimes.Pp
1908fae3551SRodney W. Grimeswhere
1918fae3551SRodney W. Grimes.Ar destination
1928fae3551SRodney W. Grimesis the destination host or network,
1938fae3551SRodney W. Grimes.Ar gateway
1948fae3551SRodney W. Grimesis the next-hop intermediary via which packets should be routed.
1958fae3551SRodney W. GrimesRoutes to a particular host may be distinguished from those to
1968fae3551SRodney W. Grimesa network by interpreting the Internet address specified as the
197ce6da1a9SRuslan Ermilov.Ar destination
198ce6da1a9SRuslan Ermilovargument.
1998fae3551SRodney W. GrimesThe optional modifiers
2008fae3551SRodney W. Grimes.Fl net
2018fae3551SRodney W. Grimesand
2028fae3551SRodney W. Grimes.Fl host
2038fae3551SRodney W. Grimesforce the destination to be interpreted as a network or a host, respectively.
2048fae3551SRodney W. GrimesOtherwise, if the
2058fae3551SRodney W. Grimes.Ar destination
20678c65517SGuy Helmerhas a
20778c65517SGuy Helmer.Dq local address part
20878c65517SGuy Helmerof
20978c65517SGuy HelmerINADDR_ANY
21078c65517SGuy Helmer.Pq Li 0.0.0.0 ,
2118fae3551SRodney W. Grimesor if the
2128fae3551SRodney W. Grimes.Ar destination
2138fae3551SRodney W. Grimesis the symbolic name of a network, then the route is
2148fae3551SRodney W. Grimesassumed to be to a network; otherwise, it is presumed to be a
2158fae3551SRodney W. Grimesroute to a host.
216ce6da1a9SRuslan ErmilovOptionally, the
217ce6da1a9SRuslan Ermilov.Ar destination
218ce6da1a9SRuslan Ermilovcould also be specified in the
2191b33d61dSRuslan Ermilov.Ar net Ns / Ns Ar bits
220ce6da1a9SRuslan Ermilovformat.
2218fae3551SRodney W. Grimes.Pp
2228fae3551SRodney W. GrimesFor example,
2238fae3551SRodney W. Grimes.Li 128.32
2248fae3551SRodney W. Grimesis interpreted as
2258fae3551SRodney W. Grimes.Fl host Li 128.0.0.32 ;
2268fae3551SRodney W. Grimes.Li 128.32.130
2278fae3551SRodney W. Grimesis interpreted as
2288fae3551SRodney W. Grimes.Fl host Li 128.32.0.130 ;
2298fae3551SRodney W. Grimes.Fl net Li 128.32
2308fae3551SRodney W. Grimesis interpreted as
2318fae3551SRodney W. Grimes.Li 128.32.0.0 ;
2328fae3551SRodney W. Grimes.Fl net Li 128.32.130
2338fae3551SRodney W. Grimesis interpreted as
234ce6da1a9SRuslan Ermilov.Li 128.32.130.0 ;
235ce6da1a9SRuslan Ermilovand
2361b33d61dSRuslan Ermilov.Li 192.168.64/20
237ce6da1a9SRuslan Ermilovis interpreted as
2381b33d61dSRuslan Ermilov.Fl net Li 192.168.64 Fl netmask Li 255.255.240.0 .
2398fae3551SRodney W. Grimes.Pp
24078c65517SGuy HelmerA
24178c65517SGuy Helmer.Ar destination
24278c65517SGuy Helmerof
24378c65517SGuy Helmer.Ar default
2449ba63ff5SHiroki Satois a synonym for the default route.
2459ba63ff5SHiroki SatoFor
2469ba63ff5SHiroki Sato.Li IPv4
2479ba63ff5SHiroki Satoit is
2489ba63ff5SHiroki Sato.Fl net Fl inet Li 0.0.0.0 ,
2499ba63ff5SHiroki Satoand for
2509ba63ff5SHiroki Sato.Li IPv6
2519ba63ff5SHiroki Satoit is
2529ba63ff5SHiroki Sato.Fl net Fl inet6 Li :: .
25378c65517SGuy Helmer.Pp
2548fae3551SRodney W. GrimesIf the destination is directly reachable
2558fae3551SRodney W. Grimesvia an interface requiring
2568fae3551SRodney W. Grimesno intermediary system to act as a gateway, the
2578fae3551SRodney W. Grimes.Fl interface
2588fae3551SRodney W. Grimesmodifier should be specified;
2598fae3551SRodney W. Grimesthe gateway given is the address of this host on the common network,
2608fae3551SRodney W. Grimesindicating the interface to be used for transmission.
261aa648cf8SJulian ElischerAlternately, if the interface is point to point the name of the interface
262aa648cf8SJulian Elischeritself may be given, in which case the route remains valid even
263072a289aSJulian Elischerif the local or remote addresses change.
2648fae3551SRodney W. Grimes.Pp
2658fae3551SRodney W. GrimesThe optional
2668fae3551SRodney W. Grimes.Fl netmask
267eee9b17eSPhilippe Charniermodifier is intended
2686dbfbe6eSGordon Berglingto achieve the effect of an OSI ESIS
2698fae3551SRodney W. Grimesredirect with the netmask option,
2708fae3551SRodney W. Grimesor to manually add subnet routes with
2718fae3551SRodney W. Grimesnetmasks different from that of the implied network interface
2728fae3551SRodney W. Grimes(as would otherwise be communicated using the OSPF or ISIS routing protocols).
2738fae3551SRodney W. GrimesOne specifies an additional ensuing address parameter
2748fae3551SRodney W. Grimes(to be interpreted as a network mask).
2758fae3551SRodney W. GrimesThe implicit network mask generated in the AF_INET case
2768fae3551SRodney W. Grimescan be overridden by making sure this option follows the destination parameter.
2778fae3551SRodney W. Grimes.Pp
278cfa1ca9dSYoshinobu InoueFor
279cfa1ca9dSYoshinobu Inoue.Dv AF_INET6 ,
280cfa1ca9dSYoshinobu Inouethe
281cfa1ca9dSYoshinobu Inoue.Fl prefixlen
282cfa1ca9dSYoshinobu Inouequalifier
283cfa1ca9dSYoshinobu Inoueis available instead of the
284cfa1ca9dSYoshinobu Inoue.Fl mask
285cfa1ca9dSYoshinobu Inouequalifier because non-continuous masks are not allowed in IPv6.
286cfa1ca9dSYoshinobu InoueFor example,
287cfa1ca9dSYoshinobu Inoue.Fl prefixlen Li 32
2888b5fede0SEnji Cooperspecifies that a network mask of
289cfa1ca9dSYoshinobu Inoue.Li ffff:ffff:0000:0000:0000:0000:0000:0000
2908b5fede0SEnji Cooperwill be used.
2918b5fede0SEnji CooperThe default prefixlen is 64.
2928b5fede0SEnji CooperHowever, it is assumed to be 0 if
293cfa1ca9dSYoshinobu Inoue.Cm default
2948b5fede0SEnji Cooperis specified for
2958b5fede0SEnji Cooper.Ar destination .
296cfa1ca9dSYoshinobu InoueNote that the qualifier works only for
297cfa1ca9dSYoshinobu Inoue.Dv AF_INET6
298cfa1ca9dSYoshinobu Inoueaddress family.
299cfa1ca9dSYoshinobu Inoue.Pp
3008fae3551SRodney W. GrimesRoutes have associated flags which influence operation of the protocols
3018fae3551SRodney W. Grimeswhen sending to destinations matched by the routes.
3028fae3551SRodney W. GrimesThese flags may be set (or sometimes cleared)
3038fae3551SRodney W. Grimesby indicating the following corresponding modifiers:
3048fae3551SRodney W. Grimes.Bd -literal
3058fae3551SRodney W. Grimes-xresolve  RTF_XRESOLVE   - emit mesg on use (for external lookup)
3068fae3551SRodney W. Grimes-iface    ~RTF_GATEWAY    - destination is directly reachable
3078fae3551SRodney W. Grimes-static    RTF_STATIC     - manually added route
3088fae3551SRodney W. Grimes-nostatic ~RTF_STATIC     - pretend route added by kernel or daemon
3098fae3551SRodney W. Grimes-reject    RTF_REJECT     - emit an ICMP unreachable when matched
3108fae3551SRodney W. Grimes-blackhole RTF_BLACKHOLE  - silently discard pkts (during updates)
3118fae3551SRodney W. Grimes-proto1    RTF_PROTO1     - set protocol specific routing flag #1
3128fae3551SRodney W. Grimes-proto2    RTF_PROTO2     - set protocol specific routing flag #2
3138fae3551SRodney W. Grimes.Ed
3148fae3551SRodney W. Grimes.Pp
3158fae3551SRodney W. GrimesThe optional modifiers
3168fae3551SRodney W. Grimes.Fl rtt ,
3178fae3551SRodney W. Grimes.Fl rttvar ,
3188fae3551SRodney W. Grimes.Fl sendpipe ,
3198fae3551SRodney W. Grimes.Fl recvpipe ,
3208fae3551SRodney W. Grimes.Fl mtu ,
3218fae3551SRodney W. Grimes.Fl hopcount ,
3228fae3551SRodney W. Grimes.Fl expire ,
3238fae3551SRodney W. Grimesand
3248fae3551SRodney W. Grimes.Fl ssthresh
3258fae3551SRodney W. Grimesprovide initial values to quantities maintained in the routing entry
3268fae3551SRodney W. Grimesby transport level protocols, such as TCP or TP4.
3278fae3551SRodney W. GrimesThese may be individually locked by preceding each such modifier to
3288fae3551SRodney W. Grimesbe locked by
3298fae3551SRodney W. Grimesthe
3308fae3551SRodney W. Grimes.Fl lock
3318fae3551SRodney W. Grimesmeta-modifier, or one can
3328fae3551SRodney W. Grimesspecify that all ensuing metrics may be locked by the
3338fae3551SRodney W. Grimes.Fl lockrest
3348fae3551SRodney W. Grimesmeta-modifier.
3358fae3551SRodney W. Grimes.Pp
336de109e29SHiroki SatoNote that
337de109e29SHiroki Sato.Fl expire
338de109e29SHiroki Satoaccepts expiration time of the route as the number of seconds since the
339de109e29SHiroki SatoEpoch
340de109e29SHiroki Sato.Pq see Xr time 3 .
341de109e29SHiroki SatoWhen the first character of the number is
342de109e29SHiroki Sato.Dq +
343de109e29SHiroki Satoor
344de109e29SHiroki Sato.Dq - ,
345de109e29SHiroki Satoit is interpreted as a value relative to the current time.
346de109e29SHiroki Sato.Pp
3479ba63ff5SHiroki SatoThe optional modifier
3489ba63ff5SHiroki Sato.Fl fib Ar number
3499ba63ff5SHiroki Satospecifies that the command will be applied to a non-default FIB.
3509ba63ff5SHiroki SatoThe
3519ba63ff5SHiroki Sato.Ar number
3529ba63ff5SHiroki Satomust be smaller than the
3539ba63ff5SHiroki Sato.Va net.fibs
3549ba63ff5SHiroki Sato.Xr sysctl 8
3559ba63ff5SHiroki SatoMIB.
3569ba63ff5SHiroki SatoWhen this modifier is not specified,
3579ba63ff5SHiroki Satoor a negative number is specified,
3589ba63ff5SHiroki Satothe default FIB shown in the
3599ba63ff5SHiroki Sato.Va net.my_fibnum
3609ba63ff5SHiroki Sato.Xr sysctl 8
3619ba63ff5SHiroki SatoMIB will be used.
3629ba63ff5SHiroki Sato.Pp
3639ba63ff5SHiroki SatoThe
3649ba63ff5SHiroki Sato.Ar number
3659ba63ff5SHiroki Satoallows multiple FIBs by a comma-separeted list and/or range
3669ba63ff5SHiroki Satospecification.
3679ba63ff5SHiroki SatoThe
3689ba63ff5SHiroki Sato.Qq Fl fib Li 2,4,6
3699ba63ff5SHiroki Satomeans the FIB number 2, 4, and 6.
3709ba63ff5SHiroki SatoThe
3719ba63ff5SHiroki Sato.Qq Fl fib Li 1,3-5,6
3729ba63ff5SHiroki Satomeans the 1, 3, 4, 5, and 6.
3739ba63ff5SHiroki Sato.Pp
3748fae3551SRodney W. GrimesIn a
3758fae3551SRodney W. Grimes.Cm change
3768fae3551SRodney W. Grimesor
3778fae3551SRodney W. Grimes.Cm add
3788fae3551SRodney W. Grimescommand where the destination and gateway are not sufficient to specify
3796dbfbe6eSGordon Berglingthe route (as in the ISO case where several interfaces may have the
3808fae3551SRodney W. Grimessame address), the
3818fae3551SRodney W. Grimes.Fl ifp
3828fae3551SRodney W. Grimesor
3838fae3551SRodney W. Grimes.Fl ifa
3848fae3551SRodney W. Grimesmodifiers may be used to determine the interface or interface address.
3858fae3551SRodney W. Grimes.Pp
3868fae3551SRodney W. GrimesAll symbolic names specified for a
3878fae3551SRodney W. Grimes.Ar destination
3888fae3551SRodney W. Grimesor
3898fae3551SRodney W. Grimes.Ar gateway
3908fae3551SRodney W. Grimesare looked up first as a host name using
3918fae3551SRodney W. Grimes.Xr gethostbyname 3 .
3928fae3551SRodney W. GrimesIf this lookup fails,
3938fae3551SRodney W. Grimes.Xr getnetbyname 3
3948fae3551SRodney W. Grimesis then used to interpret the name as that of a network.
3958fae3551SRodney W. Grimes.Pp
396629e80efSPhilippe CharnierThe
397629e80efSPhilippe Charnier.Nm
398629e80efSPhilippe Charnierutility uses a routing socket and the new message types
3991c59bf7dSRuslan Ermilov.Dv RTM_ADD , RTM_DELETE , RTM_GET ,
4008fae3551SRodney W. Grimesand
4011c59bf7dSRuslan Ermilov.Dv RTM_CHANGE .
4028fae3551SRodney W. GrimesAs such, only the super-user may modify
4038fae3551SRodney W. Grimesthe routing tables.
404b0633816SGordon Bergling.Pp
405b0633816SGordon Bergling.Fx provides support for scalable multipath routing.
406b0633816SGordon BerglingIt is activated by default, but can be turned off by setting the
407b0633816SGordon Bergling.Va net.route.multipath
408b0633816SGordon Bergling.Xr sysctl 8
409b0633816SGordon BerglingMIB to 0.
410b0633816SGordon Bergling.Pp
411b0633816SGordon BerglingThere are multiple route lookup algorithms available.
412b0633816SGordon BerglingThey can be configured by setting
413b0633816SGordon Bergling.Va net.route.algo.inet.algo
414b0633816SGordon Berglingfor IPv4 and
415b0633816SGordon Bergling.Va net.route.algo.inet6.algo
416b0633816SGordon Berglingfor IPv6
417b0633816SGordon Bergling.Xr sysctl 8
418b0633816SGordon BerglingMIBs.
419b0633816SGordon Bergling.Pp
420b0633816SGordon BerglingA list of available algorithms can be obtained by accessing the
421b0633816SGordon Berglingfollowing
422b0633816SGordon Bergling.Xr sysctl 8
423b0633816SGordon BerglingMIBs
424b0633816SGordon Bergling.Va net.route.algo.inet.algo_list
425b0633816SGordon Berglingfor IPv4 and
426b0633816SGordon Bergling.Va net.route.algo.inet6.algo_list
427b0633816SGordon Berglingfor IPv6.
428b0633816SGordon Bergling.Pp
429b0633816SGordon BerglingThe following algorithms are available:
430b0633816SGordon Bergling.Bl -tag -width radix_lockless
431b0633816SGordon Bergling.It radix
432b0633816SGordon BerglingBase system radix backend.
433b0633816SGordon Bergling.It bsearch
434b0633816SGordon BerglingLockless binary search in a special IP array, tailored for a small FIB
435b0633816SGordon Berglingwith <16 routes.
436b0633816SGordon BerglingThis algorithm is only available for IPv4.
437b0633816SGordon Bergling.It radix_lockless
438b0633816SGordon BerglingLockless immutable radix, re-created on every rtable change,
439b0633816SGordon Berglingtailored for a small FIB with <1000 routes.
440b0633816SGordon Bergling.It dpdk_lpm
441b0633816SGordon BerglingDPDK DIR24-8-based lookups, lockless datastructure, optimized
44232b28e3aSMarko Zecfor large FIBs.
44332b28e3aSMarko ZecDIR24-8 relies on a large flat lookup table (64 MB with IPv4) which is
44432b28e3aSMarko Zecdirectly indexed by the more significant portion of the lookup key.
445b0633816SGordon BerglingIn order to use the dpdk_lpm algorithm one or both of the
446b0633816SGordon Berglingfollowing kernel modules must be loaded via
447b0633816SGordon Bergling.Xr loader.conf 5 :
448b0633816SGordon Bergling.Bl -tag -width dpdk_lpm6.ko -compact
449b0633816SGordon Bergling.It dpdk_lpm4.ko
450b0633816SGordon BerglingDPDK implementation for IPv4.
451b0633816SGordon Bergling.It dpdk_lpm6.ko
452b0633816SGordon BerglingDPDK implementation for IPv6.
453b0633816SGordon Bergling.El
45432b28e3aSMarko Zec.It dxr
45532b28e3aSMarko ZecIPv4 only, lockless, compressed lookup structure
45632b28e3aSMarko Zec(below 2.5 Bytes per IPv4 prefix for large BGP FIBs)
45732b28e3aSMarko Zecwhich easily fits into modern CPU cache hierarchies,
45832b28e3aSMarko Zeclookup throughput scales linearly with CPU cores.
45932b28e3aSMarko ZecLoadable as a kernel module at runtime or via
46032b28e3aSMarko Zec.Xr loader.conf 5 :
46132b28e3aSMarko Zec.Bl -tag -width fib_dxr.ko -compact
46232b28e3aSMarko Zec.It fib_dxr.ko
46332b28e3aSMarko Zec.El
464b0633816SGordon Bergling.El
465b0633816SGordon Bergling.Pp
466b0633816SGordon BerglingThe algorithms are selected automatically based on the size of the routing
467b0633816SGordon Berglingtable of the system.
468b0633816SGordon BerglingThey can be changed, but not every algorithm performs best for every
469b0633816SGordon BerglingFIB size.
4706087df9eSRuslan Ermilov.Sh EXIT STATUS
4716087df9eSRuslan Ermilov.Ex -std
47246b035ebSJoel Dahl.Sh EXAMPLES
47346b035ebSJoel DahlAdd a default route to the network routing table.
47446b035ebSJoel DahlThis will send all packets for destinations not available in the routing table
47546b035ebSJoel Dahlto the default gateway at 192.168.1.1:
47646b035ebSJoel Dahl.Pp
47746b035ebSJoel Dahl.Dl route add -net 0.0.0.0/0 192.168.1.1
47846b035ebSJoel Dahl.Pp
47946b035ebSJoel DahlA shorter version of adding a default route can also be written as:
48046b035ebSJoel Dahl.Pp
48146b035ebSJoel Dahl.Dl route add default 192.168.1.1
48246b035ebSJoel Dahl.Pp
48346b035ebSJoel DahlAdd a static route to the 172.16.10.0/24 network via the 172.16.1.1 gateway:
48446b035ebSJoel Dahl.Pp
48546b035ebSJoel Dahl.Dl route add -net 172.16.10.0/24 172.16.1.1
48646b035ebSJoel Dahl.Pp
48746b035ebSJoel DahlChange the gateway of an already established static route in the routing table:
48846b035ebSJoel Dahl.Pp
48946b035ebSJoel Dahl.Dl route change -net 172.16.10.0/24 172.16.1.2
49046b035ebSJoel Dahl.Pp
49146b035ebSJoel DahlDisplay the route for a destination network:
49246b035ebSJoel Dahl.Pp
49346b035ebSJoel Dahl.Dl route show 172.16.10.0
49446b035ebSJoel Dahl.Pp
49546b035ebSJoel DahlDelete a static route from the routing table:
49646b035ebSJoel Dahl.Pp
49746b035ebSJoel Dahl.Dl route delete -net 172.16.10.0/24 172.16.1.2
49846b035ebSJoel Dahl.Pp
49946b035ebSJoel DahlRemove all routes from the routing table:
50046b035ebSJoel Dahl.Pp
50146b035ebSJoel Dahl.Dl route flush
502bc54f5f1SGordon Bergling.Pp
50321f26818SGordon BerglingThe routing table can be listed with
50421f26818SGordon Bergling.Xr netstat 1 .
5058fae3551SRodney W. Grimes.Sh DIAGNOSTICS
50619ab52cbSDima Dorfman.Bl -diag
50719ab52cbSDima Dorfman.It "add [host \&| network ] %s: gateway %s flags %x"
5089806e231SRuslan ErmilovThe specified route is being added to the tables.
5099806e231SRuslan ErmilovThe
5108fae3551SRodney W. Grimesvalues printed are from the routing table entry supplied
5118fae3551SRodney W. Grimesin the
5128fae3551SRodney W. Grimes.Xr ioctl 2
5138fae3551SRodney W. Grimescall.
5148fae3551SRodney W. GrimesIf the gateway address used was not the primary address of the gateway
5158fae3551SRodney W. Grimes(the first one returned by
5168fae3551SRodney W. Grimes.Xr gethostbyname 3 ) ,
5178fae3551SRodney W. Grimesthe gateway address is printed numerically as well as symbolically.
51819ab52cbSDima Dorfman.It "delete [ host \&| network ] %s: gateway %s flags %x"
5198fae3551SRodney W. GrimesAs above, but when deleting an entry.
52019ab52cbSDima Dorfman.It "%s %s done"
5218fae3551SRodney W. GrimesWhen the
5228fae3551SRodney W. Grimes.Cm flush
5238fae3551SRodney W. Grimescommand is specified, each routing table entry deleted
5248fae3551SRodney W. Grimesis indicated with a message of this form.
52519ab52cbSDima Dorfman.It "Network is unreachable"
5268fae3551SRodney W. GrimesAn attempt to add a route failed because the gateway listed was not
5278fae3551SRodney W. Grimeson a directly-connected network.
5288fae3551SRodney W. GrimesThe next-hop gateway must be given.
52919ab52cbSDima Dorfman.It "not in table"
5308fae3551SRodney W. GrimesA delete operation was attempted for an entry which
5310227791bSRuslan Ermilovwas not present in the tables.
53219ab52cbSDima Dorfman.It "routing table overflow"
5338fae3551SRodney W. GrimesAn add operation was attempted, but the system was
5348fae3551SRodney W. Grimeslow on resources and was unable to allocate memory
5358fae3551SRodney W. Grimesto create the new entry.
5361d36c899SRuslan Ermilov.It "gateway uses the same route"
5371d36c899SRuslan ErmilovA
5381d36c899SRuslan Ermilov.Cm change
5391d36c899SRuslan Ermilovoperation resulted in a route whose gateway uses the
5401d36c899SRuslan Ermilovsame route as the one being changed.
5411d36c899SRuslan ErmilovThe next-hop gateway should be reachable through a different route.
5428fae3551SRodney W. Grimes.El
5438fae3551SRodney W. Grimes.Sh SEE ALSO
544bc54f5f1SGordon Bergling.Xr netstat 1 ,
5458fae3551SRodney W. Grimes.Xr netintro 4 ,
5468fae3551SRodney W. Grimes.Xr route 4 ,
547b0633816SGordon Bergling.Xr loader.conf 5 ,
5481c59bf7dSRuslan Ermilov.Xr arp 8 ,
549bcff8e2aSMike Pritchard.Xr routed 8
5508fae3551SRodney W. Grimes.Sh HISTORY
5518fae3551SRodney W. GrimesThe
5528fae3551SRodney W. Grimes.Nm
553629e80efSPhilippe Charnierutility appeared in
5548fae3551SRodney W. Grimes.Bx 4.2 .
555