]> git.proxmox.com Git - mirror_iproute2.git/blame - man/man8/ip-route.8.in
docs: make spacing consistent
[mirror_iproute2.git] / man / man8 / ip-route.8.in
CommitLineData
e509fb1b 1.TH IP\-ROUTE 8 "13 Dec 2012" "iproute2" "Linux"
761a1e60
CT
2.SH "NAME"
3ip-route \- routing table management
4.SH "SYNOPSIS"
5.sp
6.ad l
7.in +8
8.ti -8
9.B ip
e509fb1b 10.RI "[ " ip-OPTIONS " ]"
761a1e60
CT
11.B route
12.RI " { " COMMAND " | "
13.BR help " }"
14.sp
15.ti -8
16
17.ti -8
18.BR "ip route" " { "
19.BR list " | " flush " } "
20.I SELECTOR
21
22.ti -8
23.BR "ip route save"
24.I SELECTOR
25
26.ti -8
27.BR "ip route restore"
28
29.ti -8
30.B ip route get
31.IR ADDRESS " [ "
32.BI from " ADDRESS " iif " STRING"
33.RB " ] [ " oif
34.IR STRING " ] [ "
35.B tos
36.IR TOS " ]"
37
38.ti -8
39.BR "ip route" " { " add " | " del " | " change " | " append " | "\
40replace " } "
41.I ROUTE
42
43.ti -8
44.IR SELECTOR " := "
45.RB "[ " root
46.IR PREFIX " ] [ "
47.B match
48.IR PREFIX " ] [ "
49.B exact
50.IR PREFIX " ] [ "
51.B table
52.IR TABLE_ID " ] [ "
53.B proto
54.IR RTPROTO " ] [ "
55.B type
56.IR TYPE " ] [ "
57.B scope
58.IR SCOPE " ]"
59
60.ti -8
61.IR ROUTE " := " NODE_SPEC " [ " INFO_SPEC " ]"
62
63.ti -8
64.IR NODE_SPEC " := [ " TYPE " ] " PREFIX " ["
65.B tos
66.IR TOS " ] [ "
67.B table
68.IR TABLE_ID " ] [ "
69.B proto
70.IR RTPROTO " ] [ "
71.B scope
72.IR SCOPE " ] [ "
73.B metric
74.IR METRIC " ]"
75
76.ti -8
77.IR INFO_SPEC " := " "NH OPTIONS FLAGS" " ["
78.B nexthop
79.IR NH " ] ..."
80
81.ti -8
82.IR NH " := [ "
83.B via
84.IR ADDRESS " ] [ "
85.B dev
86.IR STRING " ] [ "
87.B weight
88.IR NUMBER " ] " NHFLAGS
89
90.ti -8
91.IR OPTIONS " := " FLAGS " [ "
92.B mtu
93.IR NUMBER " ] [ "
94.B advmss
95.IR NUMBER " ] [ "
96.B rtt
97.IR TIME " ] [ "
98.B rttvar
99.IR TIME " ] [ "
4b8000f3
RG
100.B reordering
101.IR NUMBER " ] [ "
761a1e60
CT
102.B window
103.IR NUMBER " ] [ "
104.B cwnd
105.IR NUMBER " ] [ "
106.B ssthresh
107.IR REALM " ] [ "
108.B realms
109.IR REALM " ] [ "
110.B rto_min
111.IR TIME " ] [ "
112.B initcwnd
113.IR NUMBER " ] [ "
114.B initrwnd
4b8000f3 115.IR NUMBER " ] [ "
29d1f730
FW
116.B features
117.IR FEATURES " ] [ "
b37f2c89 118.B quickack
6ef87f9c
DB
119.IR BOOL " ] [ "
120.B congctl
121.IR NAME " ]"
761a1e60
CT
122
123.ti -8
124.IR TYPE " := [ "
125.BR unicast " | " local " | " broadcast " | " multicast " | "\
126throw " | " unreachable " | " prohibit " | " blackhole " | " nat " ]"
127
128.ti -8
129.IR TABLE_ID " := [ "
130.BR local "| " main " | " default " | " all " |"
131.IR NUMBER " ]"
132
133.ti -8
134.IR SCOPE " := [ "
135.BR host " | " link " | " global " |"
136.IR NUMBER " ]"
137
138.ti -8
139.IR NHFLAGS " := [ "
140.BR onlink " | " pervasive " ]"
141
142.ti -8
143.IR RTPROTO " := [ "
144.BR kernel " | " boot " | " static " |"
145.IR NUMBER " ]"
146
29d1f730
FW
147.ti -8
148.IR FEATURES " := [ "
149.BR ecn " | ]"
150
761a1e60
CT
151
152.SH DESCRIPTION
153.B ip route
154is used to manipulate entries in the kernel routing tables.
155.sp
156.B Route types:
157
158.in +8
159.B unicast
160- the route entry describes real paths to the destinations covered
161by the route prefix.
162
163.sp
164.B unreachable
a89d5329 165- these destinations are unreachable. Packets are discarded and the
761a1e60
CT
166ICMP message
167.I host unreachable
168is generated.
169The local senders get an
170.I EHOSTUNREACH
171error.
172
173.sp
174.B blackhole
a89d5329 175- these destinations are unreachable. Packets are discarded silently.
761a1e60
CT
176The local senders get an
177.I EINVAL
178error.
179
180.sp
181.B prohibit
a89d5329 182- these destinations are unreachable. Packets are discarded and the
761a1e60
CT
183ICMP message
184.I communication administratively prohibited
a89d5329 185is generated. The local senders get an
761a1e60
CT
186.I EACCES
187error.
188
189.sp
190.B local
a89d5329 191- the destinations are assigned to this host. The packets are looped
761a1e60
CT
192back and delivered locally.
193
194.sp
195.B broadcast
a89d5329 196- the destinations are broadcast addresses. The packets are sent as
761a1e60
CT
197link broadcasts.
198
199.sp
200.B throw
201- a special control route used together with policy rules. If such a
202route is selected, lookup in this table is terminated pretending that
a89d5329
203no route was found. Without policy routing it is equivalent to the
204absence of the route in the routing table. The packets are dropped
761a1e60
CT
205and the ICMP message
206.I net unreachable
a89d5329 207is generated. The local senders get an
761a1e60
CT
208.I ENETUNREACH
209error.
210
211.sp
212.B nat
a89d5329 213- a special NAT route. Destinations covered by the prefix
761a1e60 214are considered to be dummy (or external) addresses which require translation
a89d5329 215to real (or internal) ones before forwarding. The addresses to translate to
761a1e60 216are selected with the attribute
1b3c149b 217.BR "via" .
761a1e60
CT
218.B Warning:
219Route NAT is no longer supported in Linux 2.6.
220
761a1e60
CT
221.sp
222.B anycast
223.RI "- " "not implemented"
224the destinations are
225.I anycast
a89d5329 226addresses assigned to this host. They are mainly equivalent
761a1e60
CT
227to
228.B local
229with one difference: such addresses are invalid when used
230as the source address of any packet.
231
232.sp
233.B multicast
a89d5329 234- a special type used for multicast routing. It is not present in
761a1e60
CT
235normal routing tables.
236.in -8
237
238.P
239.B Route tables:
240Linux-2.x can pack routes into several routing tables identified
241by a number in the range from 1 to 2^31 or by name from the file
242.B @SYSCONFDIR@/rt_tables
243By default all normal routes are inserted into the
244.B main
245table (ID 254) and the kernel only uses this table when calculating routes.
246Values (0, 253, 254, and 255) are reserved for built-in use.
247
248.sp
249Actually, one other table always exists, which is invisible but
a89d5329 250even more important. It is the
761a1e60 251.B local
a89d5329
252table (ID 255). This table
253consists of routes for local and broadcast addresses. The kernel maintains
761a1e60
CT
254this table automatically and the administrator usually need not modify it
255or even look at it.
256
257The multiple routing tables enter the game when
258.I policy routing
259is used.
260
61f541fe 261.TP
262ip route add
263add new route
264.TP
265ip route change
266change route
267.TP
268ip route replace
269change or add new one
270.RS
761a1e60
CT
271.TP
272.BI to " TYPE PREFIX " (default)
a89d5329 273the destination prefix of the route. If
761a1e60
CT
274.I TYPE
275is omitted,
276.B ip
277assumes type
278.BR "unicast" .
279Other values of
280.I TYPE
281are listed above.
282.I PREFIX
283is an IP or IPv6 address optionally followed by a slash and the
a89d5329 284prefix length. If the length of the prefix is missing,
761a1e60 285.B ip
a89d5329 286assumes a full-length host route. There is also a special
761a1e60
CT
287.I PREFIX
288.B default
289- which is equivalent to IP
290.B 0/0
291or to IPv6
292.BR "::/0" .
293
294.TP
295.BI tos " TOS"
296.TP
297.BI dsfield " TOS"
a89d5329 298the Type Of Service (TOS) key. This key has no associated mask and
761a1e60 299the longest match is understood as: First, compare the TOS
a89d5329 300of the route and of the packet. If they are not equal, then the packet
761a1e60
CT
301may still match a route with a zero TOS.
302.I TOS
303is either an 8 bit hexadecimal number or an identifier
304from
305.BR "@SYSCONFDIR@/rt_dsfield" .
306
307.TP
308.BI metric " NUMBER"
309.TP
310.BI preference " NUMBER"
311the preference value of the route.
312.I NUMBER
313is an arbitrary 32bit number.
314
315.TP
316.BI table " TABLEID"
317the table to add this route to.
318.I TABLEID
319may be a number or a string from the file
320.BR "@SYSCONFDIR@/rt_tables" .
321If this parameter is omitted,
322.B ip
323assumes the
324.B main
325table, with the exception of
1b3c149b 326.BR local ", " broadcast " and " nat
761a1e60
CT
327routes, which are put into the
328.B local
329table by default.
330
331.TP
332.BI dev " NAME"
333the output device name.
334
335.TP
336.BI via " ADDRESS"
a89d5329
337the address of the nexthop router. Actually, the sense of this field
338depends on the route type. For normal
761a1e60
CT
339.B unicast
340routes it is either the true next hop router or, if it is a direct
341route installed in BSD compatibility mode, it can be a local address
a89d5329 342of the interface. For NAT routes it is the first address of the block
761a1e60
CT
343of translated IP destinations.
344
345.TP
346.BI src " ADDRESS"
347the source address to prefer when sending to the destinations
348covered by the route prefix.
349
350.TP
351.BI realm " REALMID"
352the realm to which this route is assigned.
353.I REALMID
354may be a number or a string from the file
355.BR "@SYSCONFDIR@/rt_realms" .
356
357.TP
358.BI mtu " MTU"
359.TP
360.BI "mtu lock" " MTU"
a89d5329 361the MTU along the path to the destination. If the modifier
761a1e60
CT
362.B lock
363is not used, the MTU may be updated by the kernel due to
a89d5329 364Path MTU Discovery. If the modifier
761a1e60
CT
365.B lock
366is used, no path MTU discovery will be tried, all packets
367will be sent without the DF bit in IPv4 case or fragmented
368to MTU for IPv6.
369
370.TP
371.BI window " NUMBER"
372the maximal window for TCP to advertise to these destinations,
a89d5329 373measured in bytes. It limits maximal data bursts that our TCP
761a1e60
CT
374peers are allowed to send to us.
375
376.TP
377.BI rtt " TIME"
378the initial RTT ('Round Trip Time') estimate. If no suffix is
379specified the units are raw values passed directly to the
380routing code to maintain compatibility with previous releases.
381Otherwise if a suffix of s, sec or secs is used to specify
382seconds and ms, msec or msecs to specify milliseconds.
383
384
385.TP
386.BI rttvar " TIME " "(2.3.15+ only)"
387the initial RTT variance estimate. Values are specified as with
388.BI rtt
389above.
390
391.TP
392.BI rto_min " TIME " "(2.6.23+ only)"
393the minimum TCP Retransmission TimeOut to use when communicating with this
a89d5329 394destination. Values are specified as with
761a1e60
CT
395.BI rtt
396above.
397
398.TP
399.BI ssthresh " NUMBER " "(2.3.15+ only)"
400an estimate for the initial slow start threshold.
401
402.TP
403.BI cwnd " NUMBER " "(2.3.15+ only)"
a89d5329 404the clamp for congestion window. It is ignored if the
761a1e60
CT
405.B lock
406flag is not used.
407
408.TP
409.BI initcwnd " NUMBER " "(2.5.70+ only)"
410the initial congestion window size for connections to this destination.
411Actual window size is this value multiplied by the MSS
412(``Maximal Segment Size'') for same connection. The default is
413zero, meaning to use the values specified in RFC2414.
414
415.TP
416.BI initrwnd " NUMBER " "(2.6.33+ only)"
417the initial receive window size for connections to this destination.
418Actual window size is this value multiplied by the MSS of the connection.
419The default value is zero, meaning to use Slow Start value.
420
29d1f730
FW
421.TP
422.BI features " FEATURES " (3.18+ only)
a89d5329 423Enable or disable per-route features. Only available feature at this
29d1f730
FW
424time is
425.B ecn
426to enable explicit congestion notification when initiating connections to the
427given destination network.
428When responding to a connection request from the given network, ecn will
429also be used even if the
430.B net.ipv4.tcp_ecn
431sysctl is set to 0.
432
b37f2c89
CW
433.TP
434.BI quickack " BOOL " "(3.11+ only)"
435Enable or disable quick ack for connections to this destination.
436
6ef87f9c
DB
437.TP
438.BI congctl " NAME " "(3.20+ only)"
439.TP
440.BI "congctl lock" " NAME " "(3.20+ only)"
441Sets a specific TCP congestion control algorithm only for a given destination.
442If not specified, Linux keeps the current global default TCP congestion control
443algorithm, or the one set from the application. If the modifier
444.B lock
445is not used, an application may nevertheless overwrite the suggested congestion
446control algorithm for that destination. If the modifier
447.B lock
448is used, then an application is not allowed to overwrite the specified congestion
449control algorithm for that destination, thus it will be enforced/guaranteed to
450use the proposed algorithm.
451
761a1e60
CT
452.TP
453.BI advmss " NUMBER " "(2.3.15+ only)"
454the MSS ('Maximal Segment Size') to advertise to these
a89d5329 455destinations when establishing TCP connections. If it is not given,
761a1e60
CT
456Linux uses a default value calculated from the first hop device MTU.
457(If the path to these destination is asymmetric, this guess may be wrong.)
458
459.TP
460.BI reordering " NUMBER " "(2.3.15+ only)"
461Maximal reordering on the path to this destination.
462If it is not given, Linux uses the value selected with
463.B sysctl
464variable
465.BR "net/ipv4/tcp_reordering" .
466
467.TP
468.BI nexthop " NEXTHOP"
469the nexthop of a multipath route.
470.I NEXTHOP
471is a complex value with its own syntax similar to the top level
472argument lists:
473
474.in +8
475.BI via " ADDRESS"
476- is the nexthop router.
477.sp
478
479.BI dev " NAME"
480- is the output device.
481.sp
482
483.BI weight " NUMBER"
484- is a weight for this element of a multipath
485route reflecting its relative bandwidth or quality.
486.in -8
487
488.TP
489.BI scope " SCOPE_VAL"
490the scope of the destinations covered by the route prefix.
491.I SCOPE_VAL
492may be a number or a string from the file
493.BR "@SYSCONFDIR@/rt_scopes" .
494If this parameter is omitted,
495.B ip
496assumes scope
497.B global
498for all gatewayed
499.B unicast
500routes, scope
501.B link
502for direct
503.BR unicast " and " broadcast
504routes and scope
505.BR host " for " local
506routes.
507
508.TP
509.BI protocol " RTPROTO"
510the routing protocol identifier of this route.
511.I RTPROTO
512may be a number or a string from the file
513.BR "@SYSCONFDIR@/rt_protos" .
514If the routing protocol ID is not given,
515.B ip assumes protocol
516.B boot
517(i.e. it assumes the route was added by someone who doesn't
a89d5329 518understand what they are doing). Several protocol values have
761a1e60
CT
519a fixed interpretation.
520Namely:
521
522.in +8
523.B redirect
524- the route was installed due to an ICMP redirect.
525.sp
526
527.B kernel
528- the route was installed by the kernel during autoconfiguration.
529.sp
530
531.B boot
532- the route was installed during the bootup sequence.
533If a routing daemon starts, it will purge all of them.
534.sp
535
536.B static
537- the route was installed by the administrator
538to override dynamic routing. Routing daemon will respect them
539and, probably, even advertise them to its peers.
540.sp
541
542.B ra
543- the route was installed by Router Discovery protocol.
544.in -8
545
546.sp
547The rest of the values are not reserved and the administrator is free
548to assign (or not to assign) protocol tags.
549
550.TP
551.B onlink
552pretend that the nexthop is directly attached to this link,
553even if it does not match any interface prefix.
61f541fe 554.RE
761a1e60 555
61f541fe 556.TP
557ip route delete
558delete route
559.RS
761a1e60
CT
560.B ip route del
561has the same arguments as
562.BR "ip route add" ,
563but their semantics are a bit different.
564
565Key values
566.RB "(" to ", " tos ", " preference " and " table ")"
a89d5329 567select the route to delete. If optional attributes are present,
761a1e60
CT
568.B ip
569verifies that they coincide with the attributes of the route to delete.
570If no route with the given key and attributes was found,
571.B ip route del
572fails.
61f541fe 573.RE
761a1e60 574
61f541fe 575.TP
576ip route show
577list routes
578.RS
761a1e60
CT
579the command displays the contents of the routing tables or the route(s)
580selected by some criteria.
581
582.TP
583.BI to " SELECTOR " (default)
584only select routes from the given range of destinations.
585.I SELECTOR
586consists of an optional modifier
587.RB "(" root ", " match " or " exact ")"
588and a prefix.
589.BI root " PREFIX"
590selects routes with prefixes not shorter than
591.IR PREFIX "."
592F.e.
593.BI root " 0/0"
594selects the entire routing table.
595.BI match " PREFIX"
596selects routes with prefixes not longer than
597.IR PREFIX "."
598F.e.
599.BI match " 10.0/16"
600selects
601.IR 10.0/16 ","
602.IR 10/8 " and " 0/0 ,
603but it does not select
604.IR 10.1/16 " and " 10.0.0/24 .
605And
606.BI exact " PREFIX"
607(or just
608.IR PREFIX ")"
609selects routes with this exact prefix. If neither of these options
610are present,
611.B ip
612assumes
613.BI root " 0/0"
614i.e. it lists the entire table.
615
616.TP
617.BI tos " TOS"
1b3c149b 618.TP
761a1e60
CT
619.BI dsfield " TOS"
620only select routes with the given TOS.
621
622.TP
623.BI table " TABLEID"
a89d5329 624show the routes from this table(s). The default setting is to show table
1b3c149b 625.BR main "."
761a1e60
CT
626.I TABLEID
627may either be the ID of a real table or one of the special values:
628.sp
629.in +8
630.B all
631- list all of the tables.
632.sp
633.B cache
634- dump the routing cache.
635.in -8
636
637.TP
638.B cloned
639.TP
640.B cached
641list cloned routes i.e. routes which were dynamically forked from
642other routes because some route attribute (f.e. MTU) was updated.
643Actually, it is equivalent to
644.BR "table cache" "."
645
646.TP
647.BI from " SELECTOR"
648the same syntax as for
649.BR to ","
650but it binds the source address range rather than destinations.
651Note that the
652.B from
653option only works with cloned routes.
654
655.TP
656.BI protocol " RTPROTO"
657only list routes of this protocol.
658
659.TP
660.BI scope " SCOPE_VAL"
661only list routes with this scope.
662
663.TP
664.BI type " TYPE"
665only list routes of this type.
666
667.TP
668.BI dev " NAME"
669only list routes going via this device.
670
671.TP
672.BI via " PREFIX"
673only list routes going via the nexthop routers selected by
674.IR PREFIX "."
675
676.TP
677.BI src " PREFIX"
678only list routes with preferred source addresses selected
679by
680.IR PREFIX "."
681
682.TP
683.BI realm " REALMID"
684.TP
685.BI realms " FROMREALM/TOREALM"
686only list routes with these realms.
61f541fe 687.RE
761a1e60 688
61f541fe 689.TP
690ip route flush
691flush routing tables
692.RS
761a1e60
CT
693this command flushes routes selected by some criteria.
694
695.sp
696The arguments have the same syntax and semantics as the arguments of
697.BR "ip route show" ,
a89d5329 698but routing tables are not listed but purged. The only difference is
761a1e60
CT
699the default action:
700.B show
701dumps all the IP main routing table but
702.B flush
703prints the helper page.
704
705.sp
706With the
707.B -statistics
708option, the command becomes verbose. It prints out the number of
709deleted routes and the number of rounds made to flush the routing
710table. If the option is given
711twice,
712.B ip route flush
713also dumps all the deleted routes in the format described in the
714previous subsection.
61f541fe 715.RE
761a1e60 716
61f541fe 717.TP
718ip route get
719get a single route
720.RS
761a1e60
CT
721this command gets a single route to a destination and prints its
722contents exactly as the kernel sees it.
723
724.TP
725.BI to " ADDRESS " (default)
726the destination address.
727
728.TP
729.BI from " ADDRESS"
730the source address.
731
732.TP
733.BI tos " TOS"
734.TP
735.BI dsfield " TOS"
736the Type Of Service.
737
738.TP
739.BI iif " NAME"
740the device from which this packet is expected to arrive.
741
742.TP
743.BI oif " NAME"
744force the output device on which this packet will be routed.
745
746.TP
747.B connected
748if no source address
749.RB "(option " from ")"
750was given, relookup the route with the source set to the preferred
751address received from the first lookup.
752If policy routing is used, it may be a different route.
753
754.P
755Note that this operation is not equivalent to
756.BR "ip route show" .
757.B show
758shows existing routes.
759.B get
a89d5329 760resolves them and creates new clones if necessary. Essentially,
761a1e60
CT
761.B get
762is equivalent to sending a packet along this path.
763If the
764.B iif
765argument is not given, the kernel creates a route
766to output packets towards the requested destination.
767This is equivalent to pinging the destination
768with a subsequent
769.BR "ip route ls cache" ,
a89d5329 770however, no packets are actually sent. With the
761a1e60
CT
771.B iif
772argument, the kernel pretends that a packet arrived from this interface
773and searches for a path to forward the packet.
61f541fe 774.RE
761a1e60 775
61f541fe 776.TP
777ip route save
778save routing table information to stdout
779.RS
780This command behaves like
761a1e60
CT
781.BR "ip route show"
782except that the output is raw data suitable for passing to
783.BR "ip route restore" .
61f541fe 784.RE
761a1e60 785
61f541fe 786.TP
787ip route restore
788restore routing table information from stdin
789.RS
790This command expects to read a data stream as returned from
761a1e60
CT
791.BR "ip route save" .
792It will attempt to restore the routing table information exactly as
793it was at the time of the save, so any translation of information
a89d5329
794in the stream (such as device indexes) must be done first. Any existing
795routes are left unchanged. Any routes specified in the data stream that
761a1e60 796already exist in the table will be ignored.
61f541fe 797.RE
761a1e60
CT
798
799.SH EXAMPLES
800.PP
801ip ro
802.RS 4
803Show all route entries in the kernel.
804.RE
805.PP
806ip route add default via 192.168.1.1 dev eth0
807.RS 4
808Adds a default route (for all addresses) via the local gateway 192.168.1.1 that can
809be reached on device eth0.
810.RE
811
812.SH SEE ALSO
813.br
814.BR ip (8)
815
816.SH AUTHOR
817Original Manpage by Michail Litvak <mci@owl.openwall.com>