Debian Codegraph @

upstream/debian-unstable/man8/ip-route.8

raw
1 .TH IP\-ROUTE 8 "13 Dec 2012" "iproute2" "Linux"
2 .SH "NAME"
3 ip-route \- routing table management
4 .SH "SYNOPSIS"
5 .sp
6 .ad l
7 .in +8
8 .ti -8
9 .B ip
10 .RI "[ " ip-OPTIONS " ]"
11 .B route
12 .RI " { " COMMAND " | "
13 .BR help " }"
14 .sp
15 .ti -8
16
17 .ti -8
18 .BR "ip route" " { "
19 .BR show " | " 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 .I ROUTE_GET_FLAGS
32 .B [ to ]
33 .IR ADDRESS " [ "
34 .BI from " ADDRESS " iif " STRING"
35 .RB " ] [ " oif
36 .IR STRING " ] [ "
37 .B mark
38 .IR MARK " ] [ "
39 .B tos
40 .IR TOS " ] [ "
41 .B vrf
42 .IR NAME " ] [ "
43 .B ipproto
44 .IR PROTOCOL " ] [ "
45 .B sport
46 .IR NUMBER " ] [ "
47 .B dport
48 .IR NUMBER " ] ["
49 .B as
50 .IR ADDRESS " ] ["
51 .B flowlabel
52 .IR FLOWLABEL " ]
53
54 .ti -8
55 .BR "ip route" " { " add " | " del " | " change " | " append " | "\
56 replace " } "
57 .I ROUTE
58
59 .ti -8
60 .IR SELECTOR " := "
61 .RB "[ " root
62 .IR PREFIX " ] [ "
63 .B match
64 .IR PREFIX " ] [ "
65 .B exact
66 .IR PREFIX " ] [ "
67 .B table
68 .IR TABLE_ID " ] [ "
69 .B vrf
70 .IR NAME " ] [ "
71 .B proto
72 .IR RTPROTO " ] [ "
73 .B type
74 .IR TYPE " ] [ "
75 .B scope
76 .IR SCOPE " ]"
77
78 .ti -8
79 .IR ROUTE " := " NODE_SPEC " [ " INFO_SPEC " ]"
80
81 .ti -8
82 .IR NODE_SPEC " := [ " TYPE " ] " PREFIX " ["
83 .B tos
84 .IR TOS " ] [ "
85 .B table
86 .IR TABLE_ID " ] [ "
87 .B proto
88 .IR RTPROTO " ] [ "
89 .B scope
90 .IR SCOPE " ] [ "
91 .B metric
92 .IR METRIC " ] [ "
93 .B ttl-propagate
94 .RB "{ " enabled " | " disabled " } ]"
95
96 .ti -8
97 .IR INFO_SPEC " := { " NH " | "
98 .B nhid
99 .IR ID " } " "OPTIONS FLAGS" " ["
100 .B nexthop
101 .IR NH " ] ..."
102
103 .ti -8
104 .IR NH " := [ "
105 .B encap
106 .IR ENCAP " ] [ "
107 .B via
108 [
109 .IR FAMILY " ] " ADDRESS " ] [ "
110 .B dev
111 .IR STRING " ] [ "
112 .B weight
113 .IR NUMBER " ] " NHFLAGS
114
115 .ti -8
116 .IR FAMILY " := [ "
117 .BR inet " | " inet6 " | " mpls " | " bridge " | " link " ]"
118
119 .ti -8
120 .IR OPTIONS " := " FLAGS " [ "
121 .B mtu
122 .IR NUMBER " ] [ "
123 .B advmss
124 .IR NUMBER " ] [ "
125 .B as
126 [
127 .B to
128 ]
129 .IR ADDRESS " ]"
130 .B rtt
131 .IR TIME " ] [ "
132 .B rttvar
133 .IR TIME " ] [ "
134 .B reordering
135 .IR NUMBER " ] [ "
136 .B window
137 .IR NUMBER " ] [ "
138 .B cwnd
139 .IR NUMBER " ] [ "
140 .B ssthresh
141 .IR NUMBER " ] [ "
142 .B realms
143 .IR REALM " ] [ "
144 .B rto_min
145 .IR TIME " ] [ "
146 .B initcwnd
147 .IR NUMBER " ] [ "
148 .B initrwnd
149 .IR NUMBER " ] [ "
150 .B features
151 .IR FEATURES " ] [ "
152 .B quickack
153 .IR BOOL " ] [ "
154 .B congctl
155 .IR NAME " ] [ "
156 .B pref
157 .IR PREF " ] [ "
158 .B expires
159 .IR TIME " ] ["
160 .B fastopen_no_cookie
161 .IR BOOL " ]"
162
163 .ti -8
164 .IR TYPE " := [ "
165 .BR unicast " | " local " | " broadcast " | " multicast " | "\
166 throw " | " unreachable " | " prohibit " | " blackhole " | " nat " ]"
167
168 .ti -8
169 .IR TABLE_ID " := [ "
170 .BR local "| " main " | " default " | " all " |"
171 .IR NUMBER " ]"
172
173 .ti -8
174 .IR SCOPE " := [ "
175 .BR host " | " link " | " global " |"
176 .IR NUMBER " ]"
177
178 .ti -8
179 .IR NHFLAGS " := [ "
180 .BR onlink " | " pervasive " ]"
181
182 .ti -8
183 .IR RTPROTO " := [ "
184 .BR kernel " | " boot " | " static " |"
185 .IR NUMBER " ]"
186
187 .ti -8
188 .IR FEATURES " := [ "
189 .BR ecn " | ]"
190
191 .ti -8
192 .IR PREF " := [ "
193 .BR low " | " medium " | " high " ]"
194
195 .ti -8
196 .IR ENCAP " := [ "
197 .IR ENCAP_MPLS " | " ENCAP_IP " | " ENCAP_BPF " | "
198 .IR ENCAP_SEG6 " | " ENCAP_SEG6LOCAL " | " ENCAP_IOAM6 " ] "
199
200 .ti -8
201 .IR ENCAP_MPLS " := "
202 .BR mpls " [ "
203 .IR LABEL " ] ["
204 .B ttl
205 .IR TTL " ]"
206
207 .ti -8
208 .IR ENCAP_IP " := "
209 .B ip
210 .B id
211 .IR TUNNEL_ID
212 .B dst
213 .IR REMOTE_IP " [ "
214 .B src
215 .IR SRC " ] ["
216 .B tos
217 .IR TOS " ] ["
218 .B ttl
219 .IR TTL " ] ["
220 .BR key " ] ["
221 .BR csum " ] ["
222 .BR seq " ] ["
223 .IR GENEVE_OPTS " | "
224 .IR VXLAN_OPTS " | "
225 .IR ERSPAN_OPTS " ]"
226
227 .ti -8
228 .IR ENCAP_BPF " := "
229 .BR bpf " [ "
230 .B in
231 .IR PROG " ] ["
232 .B out
233 .IR PROG " ] ["
234 .B xmit
235 .IR PROG " ] ["
236 .B headroom
237 .IR SIZE " ]"
238
239 .ti -8
240 .IR ENCAP_SEG6 " := "
241 .B seg6
242 .BR mode " [ "
243 .BR encap " | " encap.red " | " inline " | " l2encap " | " l2encap.red " ] "
244 .B segs
245 .IR SEGMENTS " [ "
246 .B hmac
247 .IR KEYID " ]"
248
249 .ti -8
250 .IR ENCAP_SEG6LOCAL " := "
251 .B seg6local
252 .BR action
253 .IR SEG6_ACTION " [ "
254 .IR SEG6_ACTION_PARAM " ] [ "
255 .BR count " ] "
256
257 .ti -8
258 .IR ENCAP_IOAM6 " := "
259 .BR ioam6 " ["
260 .B freq
261 .IR K "/" N " ] "
262 .BR mode " [ "
263 .BR inline " | " encap " | " auto " ] ["
264 .B tunsrc
265 .IR ADDRESS " ] ["
266 .B tundst
267 .IR ADDRESS " ] "
268 .B trace
269 .B prealloc
270 .B type
271 .IR IOAM6_TRACE_TYPE
272 .B ns
273 .IR IOAM6_NAMESPACE
274 .B size
275 .IR IOAM6_TRACE_SIZE
276
277 .ti -8
278 .IR ROUTE_GET_FLAGS " := "
279 .IR ROUTE_GET_FLAG " [ "
280 .IR ROUTE_GET_FLAGS " ] "
281
282 .ti -8
283 .IR ROUTE_GET_FLAG " := "
284 .BR "[ "
285 .BR connected " | " fibmatch " | " notify
286 .BR "]"
287
288 .SH DESCRIPTION
289 .B ip route
290 is used to manipulate entries in the kernel routing tables.
291 .sp
292 .B Route types:
293
294 .in +8
295 .B unicast
296 - the route entry describes real paths to the destinations covered
297 by the route prefix.
298
299 .sp
300 .B unreachable
301 - these destinations are unreachable. Packets are discarded and the
302 ICMP message
303 .I host unreachable
304 is generated.
305 The local senders get an
306 .I EHOSTUNREACH
307 error.
308
309 .sp
310 .B blackhole
311 - these destinations are unreachable. Packets are discarded silently.
312 The local senders get an
313 .I EINVAL
314 error.
315
316 .sp
317 .B prohibit
318 - these destinations are unreachable. Packets are discarded and the
319 ICMP message
320 .I communication administratively prohibited
321 is generated. The local senders get an
322 .I EACCES
323 error.
324
325 .sp
326 .B local
327 - the destinations are assigned to this host. The packets are looped
328 back and delivered locally.
329
330 .sp
331 .B broadcast
332 - the destinations are broadcast addresses. The packets are sent as
333 link broadcasts.
334
335 .sp
336 .B throw
337 - a special control route used together with policy rules. If such a
338 route is selected, lookup in this table is terminated pretending that
339 no route was found. Without policy routing it is equivalent to the
340 absence of the route in the routing table. The packets are dropped
341 and the ICMP message
342 .I net unreachable
343 is generated. The local senders get an
344 .I ENETUNREACH
345 error.
346
347 .sp
348 .B nat
349 - a special NAT route. Destinations covered by the prefix
350 are considered to be dummy (or external) addresses which require translation
351 to real (or internal) ones before forwarding. The addresses to translate to
352 are selected with the attribute
353 .BR "via" .
354 .B Warning:
355 Route NAT is no longer supported in Linux 2.6.
356
357 .sp
358 .B anycast
359 .RI "- " "not implemented"
360 the destinations are
361 .I anycast
362 addresses assigned to this host. They are mainly equivalent
363 to
364 .B local
365 with one difference: such addresses are invalid when used
366 as the source address of any packet.
367
368 .sp
369 .B multicast
370 - a special type used for multicast routing. It is not present in
371 normal routing tables.
372 .in -8
373
374 .P
375 .B Route tables:
376 Linux-2.x can pack routes into several routing tables identified
377 by a number in the range from 1 to 2^32-1 or by name from
378 .BR /usr/share/iproute2/rt_tables " or " /etc/iproute2/rt_tables
379 (has precedence if exists).
380 By default all normal routes are inserted into the
381 .B main
382 table (ID 254) and the kernel only uses this table when calculating routes.
383 Values (0, 253, 254, and 255) are reserved for built-in use.
384
385 .sp
386 Actually, one other table always exists, which is invisible but
387 even more important. It is the
388 .B local
389 table (ID 255). This table
390 consists of routes for local and broadcast addresses. The kernel maintains
391 this table automatically and the administrator usually need not modify it
392 or even look at it.
393
394 The multiple routing tables enter the game when
395 .I policy routing
396 is used.
397
398 .TP
399 ip route add
400 add new route
401 .TP
402 ip route change
403 change route
404 .TP
405 ip route replace
406 change or add new one
407 .RS
408 .TP
409 .BI to " TYPE PREFIX " (default)
410 the destination prefix of the route. If
411 .I TYPE
412 is omitted,
413 .B ip
414 assumes type
415 .BR "unicast" .
416 Other values of
417 .I TYPE
418 are listed above.
419 .I PREFIX
420 is an IP or IPv6 address optionally followed by a slash and the
421 prefix length. If the length of the prefix is missing,
422 .B ip
423 assumes a full-length host route. There is also a special
424 .I PREFIX
425 .B default
426 - which is equivalent to IP
427 .B 0/0
428 or to IPv6
429 .BR "::/0" .
430
431 .TP
432 .BI tos " TOS"
433 .TP
434 .BI dsfield " TOS"
435 the Type Of Service (TOS) key. This key has no associated mask and
436 the longest match is understood as: First, compare the TOS
437 of the route and of the packet. If they are not equal, then the packet
438 may still match a route with a zero TOS.
439 .I TOS
440 is either an 8 bit hexadecimal number or an identifier
441 from
442 .BR /usr/share/iproute2/rt_dsfield " or " /etc/iproute2/rt_dsfield
443 (has precedence if exists).
444
445 .TP
446 .BI metric " NUMBER"
447 .TP
448 .BI preference " NUMBER"
449 the preference value of the route.
450 .I NUMBER
451 is an arbitrary 32bit number, where routes with lower values are preferred.
452
453 .TP
454 .BI table " TABLEID"
455 the table to add this route to.
456 .I TABLEID
457 may be a number or a string from
458 .BR /usr/share/iproute2/rt_tables " or " /etc/iproute2/rt_tables
459 (has precedence if exists).
460 If this parameter is omitted,
461 .B ip
462 assumes the
463 .B main
464 table, with the exception of
465 .BR local ", " broadcast " and " nat
466 routes, which are put into the
467 .B local
468 table by default.
469
470 .TP
471 .BI vrf " NAME"
472 the vrf name to add this route to. Implicitly means the table
473 associated with the VRF.
474
475 .TP
476 .BI dev " NAME"
477 the output device name.
478
479 .TP
480 .BI via " [ FAMILY ] ADDRESS"
481 the address of the nexthop router, in the address family FAMILY.
482 Actually, the sense of this field depends on the route type. For
483 normal
484 .B unicast
485 routes it is either the true next hop router or, if it is a direct
486 route installed in BSD compatibility mode, it can be a local address
487 of the interface. For NAT routes it is the first address of the block
488 of translated IP destinations.
489
490 .TP
491 .BI src " ADDRESS"
492 the source address to prefer when sending to the destinations
493 covered by the route prefix.
494
495 .TP
496 .BI realm " REALMID"
497 the realm to which this route is assigned.
498 .I REALMID
499 may be a number or a string from
500 .BR /usr/share/iproute2/rt_realms " or " /etc/iproute2/rt_realms
501 (has precedence if exists).
502
503 .TP
504 .BI mtu " MTU"
505 .TP
506 .BI "mtu lock" " MTU"
507 the MTU along the path to the destination. If the modifier
508 .B lock
509 is not used, the MTU may be updated by the kernel due to
510 Path MTU Discovery. If the modifier
511 .B lock
512 is used, no path MTU discovery will be tried, all packets
513 will be sent without the DF bit in IPv4 case or fragmented
514 to MTU for IPv6.
515
516 .TP
517 .BI window " NUMBER"
518 the maximal window for TCP to advertise to these destinations,
519 measured in bytes. It limits maximal data bursts that our TCP
520 peers are allowed to send to us.
521
522 .TP
523 .BI rtt " TIME"
524 the initial RTT ('Round Trip Time') estimate. If no suffix is
525 specified the units are raw values passed directly to the
526 routing code to maintain compatibility with previous releases.
527 Otherwise if a suffix of s, sec or secs is used to specify
528 seconds and ms, msec or msecs to specify milliseconds.
529
530
531 .TP
532 .BI rttvar " TIME " "(Linux 2.3.15+ only)"
533 the initial RTT variance estimate. Values are specified as with
534 .BI rtt
535 above.
536
537 .TP
538 .BI rto_min " TIME " "(Linux 2.6.23+ only)"
539 the minimum TCP Retransmission TimeOut to use when communicating with this
540 destination. Values are specified as with
541 .BI rtt
542 above.
543
544 .TP
545 .BI ssthresh " NUMBER " "(Linux 2.3.15+ only)"
546 an estimate for the initial slow start threshold.
547
548 .TP
549 .BI cwnd " NUMBER " "(Linux 2.3.15+ only)"
550 the clamp for congestion window. It is ignored if the
551 .B lock
552 flag is not used.
553
554 .TP
555 .BI initcwnd " NUMBER " "(Linux 2.5.70+ only)"
556 the initial congestion window size for connections to this destination.
557 Actual window size is this value multiplied by the MSS
558 (``Maximal Segment Size'') for same connection. The default is
559 zero, meaning to use the values specified in RFC2414.
560
561 .TP
562 .BI initrwnd " NUMBER " "(Linux 2.6.33+ only)"
563 the initial receive window size for connections to this destination.
564 Actual window size is this value multiplied by the MSS of the connection.
565 The default value is zero, meaning to use Slow Start value.
566
567 .TP
568 .BI features " FEATURES " (Linux 3.18+ only)
569 Enable or disable per-route features. Only available feature at this
570 time is
571 .B ecn
572 to enable explicit congestion notification when initiating connections to the
573 given destination network.
574 When responding to a connection request from the given network, ecn will
575 also be used even if the
576 .B net.ipv4.tcp_ecn
577 sysctl is set to 0.
578
579 .TP
580 .BI quickack " BOOL " "(Linux 3.11+ only)"
581 Enable or disable quick ack for connections to this destination.
582
583 .TP
584 .BI fastopen_no_cookie " BOOL " "(Linux 4.15+ only)"
585 Enable TCP Fastopen without a cookie for connections to this destination.
586
587 .TP
588 .BI congctl " NAME " "(Linux 3.20+ only)"
589 .TP
590 .BI "congctl lock" " NAME " "(Linux 3.20+ only)"
591 Sets a specific TCP congestion control algorithm only for a given destination.
592 If not specified, Linux keeps the current global default TCP congestion control
593 algorithm, or the one set from the application. If the modifier
594 .B lock
595 is not used, an application may nevertheless overwrite the suggested congestion
596 control algorithm for that destination. If the modifier
597 .B lock
598 is used, then an application is not allowed to overwrite the specified congestion
599 control algorithm for that destination, thus it will be enforced/guaranteed to
600 use the proposed algorithm.
601
602 .TP
603 .BI advmss " NUMBER " "(Linux 2.3.15+ only)"
604 the MSS ('Maximal Segment Size') to advertise to these
605 destinations when establishing TCP connections. If it is not given,
606 Linux uses a default value calculated from the first hop device MTU.
607 (If the path to these destination is asymmetric, this guess may be wrong.)
608
609 .TP
610 .BI reordering " NUMBER " "(Linux 2.3.15+ only)"
611 Maximal reordering on the path to this destination.
612 If it is not given, Linux uses the value selected with
613 .B sysctl
614 variable
615 .BR "net/ipv4/tcp_reordering" .
616
617 .TP
618 .BI nexthop " NEXTHOP"
619 the nexthop of a multipath route.
620 .I NEXTHOP
621 is a complex value with its own syntax similar to the top level
622 argument lists:
623
624 .in +8
625 .BI via " [ FAMILY ] ADDRESS"
626 - is the nexthop router.
627 .sp
628
629 .BI dev " NAME"
630 - is the output device.
631 .sp
632
633 .BI weight " NUMBER"
634 - is a weight for this element of a multipath
635 route reflecting its relative bandwidth or quality.
636 .in -8
637
638 The internal buffer used in iproute2 limits the maximum number of nexthops that
639 may be specified in one go. If only
640 .I ADDRESS
641 is given, the current buffer size allows for 144 IPv6 nexthops and 253 IPv4
642 ones. For IPv4, this effectively limits the number of nexthops possible per
643 route. With IPv6, further nexthops may be appended to the same route via
644 .B "ip route append"
645 command.
646
647 .TP
648 .BI scope " SCOPE_VAL"
649 the scope of the destinations covered by the route prefix.
650 .I SCOPE_VAL
651 may be a number or a string from
652 .BR /usr/share/iproute2/rt_scopes " or " /etc/iproute2/rt_scopes
653 (has precedence if exists).
654 If this parameter is omitted,
655 .B ip
656 assumes scope
657 .B global
658 for all gatewayed
659 .B unicast
660 routes, scope
661 .B link
662 for direct
663 .BR unicast " and " broadcast
664 routes and scope
665 .BR host " for " local
666 routes.
667
668 .TP
669 .BI protocol " RTPROTO"
670 the routing protocol identifier of this route.
671 .I RTPROTO
672 may be a number or a string from
673 .BR /usr/share/iproute2/rt_protos " or " /etc/iproute2/rt_protos
674 (has precedence if exists).
675 If the routing protocol ID is not given,
676 .B ip assumes protocol
677 .B boot
678 (i.e. it assumes the route was added by someone who doesn't
679 understand what they are doing). Several protocol values have
680 a fixed interpretation.
681 Namely:
682
683 .in +8
684 .B redirect
685 - the route was installed due to an ICMP redirect.
686 .sp
687
688 .B kernel
689 - the route was installed by the kernel during autoconfiguration.
690 .sp
691
692 .B boot
693 - the route was installed during the bootup sequence.
694 If a routing daemon starts, it will purge all of them.
695 .sp
696
697 .B static
698 - the route was installed by the administrator
699 to override dynamic routing. Routing daemon will respect them
700 and, probably, even advertise them to its peers.
701 .sp
702
703 .B ra
704 - the route was installed by Router Discovery protocol.
705 .in -8
706
707 .sp
708 The rest of the values are not reserved and the administrator is free
709 to assign (or not to assign) protocol tags.
710
711 .TP
712 .B onlink
713 pretend that the nexthop is directly attached to this link,
714 even if it does not match any interface prefix.
715
716 .TP
717 .BI pref " PREF"
718 the IPv6 route preference.
719 .I PREF
720 is a string specifying the route preference as defined in RFC4191 for Router
721 Discovery messages. Namely:
722
723 .in +8
724 .B low
725 - the route has a lowest priority
726 .sp
727
728 .B medium
729 - the route has a default priority
730 .sp
731
732 .B high
733 - the route has a highest priority
734 .sp
735
736 .TP
737 .BI nhid " ID"
738 use nexthop object with given id as nexthop specification.
739 .sp
740 .TP
741 .BI encap " ENCAPTYPE ENCAPHDR"
742 attach tunnel encapsulation attributes to this route.
743 .sp
744 .I ENCAPTYPE
745 is a string specifying the supported encapsulation type. Namely:
746
747 .in +8
748 .BI mpls
749 - encapsulation type MPLS
750 .sp
751 .BI ip
752 - IP encapsulation (Geneve, GRE, VXLAN, ...)
753 .sp
754 .BI bpf
755 - Execution of BPF program
756 .sp
757 .BI seg6
758 - encapsulation type IPv6 Segment Routing
759 .sp
760 .BI seg6local
761 - local SRv6 segment processing
762 .sp
763 .BI ioam6
764 - encapsulation type IPv6 IOAM
765 .sp
766 .BI xfrm
767 - encapsulation type XFRM
768
769 .in -8
770 .I ENCAPHDR
771 is a set of encapsulation attributes specific to the
772 .I ENCAPTYPE.
773
774 .in +8
775 .B mpls
776 .in +2
777 .I MPLSLABEL
778 - mpls label stack with labels separated by
779 .I "/"
780 .sp
781
782 .B ttl
783 .I TTL
784 - TTL to use for MPLS header or 0 to inherit from IP header
785 .in -2
786 .sp
787
788 .B ip
789 .in +2
790 .B id
791 .I TUNNEL_ID
792 - Tunnel ID (for example VNI in VXLAN tunnel)
793 .sp
794
795 .B dst
796 .I REMOTE_IP
797 - Outer header destination IP address (IPv4 or IPv6)
798 .sp
799
800 .B src
801 .I SRC
802 - Outer header source IP address (IPv4 or IPv6)
803 .sp
804
805 .B tos
806 .I TOS
807 - Outer header TOS
808 .sp
809
810 .B ttl
811 .I TTL
812 - Outer header TTL
813 .sp
814
815 .B key
816 - Outer header flags with key in GRE tunnel
817 .sp
818
819 .B csum
820 - Outer header flags with csum in GRE tunnel
821 .sp
822
823 .B seq
824 - Outer header flags with seq in GRE tunnel
825 .sp
826
827 .I GENEVE_OPTS
828 - Specified in the form CLASS:TYPE:DATA, where CLASS is represented as a
829 16bit hexadecimal value, TYPE as an 8bit hexadecimal value and DATA as a
830 variable length hexadecimal value. Additionally multiple options may be
831 listed using a comma delimiter.
832 .sp
833
834 .I VXLAN_OPTS
835 - Specified in the form GBP, as a 32bit number. Multiple options is not
836 supported.
837 .sp
838
839 .I ERSPAN_OPTS
840 - Specified in the form VERSION:INDEX:DIR:HWID, where VERSION is represented
841 as a 8bit number, INDEX as an 32bit number, DIR and HWID as a 8bit number.
842 Multiple options is not supported. Note INDEX is used when VERSION is 1,
843 and DIR and HWID are used when VERSION is 2.
844 .in -2
845 .sp
846
847 .B bpf
848 .in +2
849 .B in
850 .I PROG
851 - BPF program to execute for incoming packets
852 .sp
853
854 .B out
855 .I PROG
856 - BPF program to execute for outgoing packets
857 .sp
858
859 .B xmit
860 .I PROG
861 - BPF program to execute for transmitted packets
862 .sp
863
864 .B headroom
865 .I SIZE
866 - Size of header BPF program will attach (xmit)
867 .in -2
868 .sp
869
870 .B seg6
871 .in +2
872 .B mode inline
873 - Directly insert Segment Routing Header after IPv6 header
874 .sp
875
876 .B mode encap
877 - Encapsulate packet in an outer IPv6 header with SRH
878 .sp
879
880 .B mode encap.red
881 - Encapsulate packet in an outer IPv6 header with SRH applying the
882 reduced segment list. When there is only one segment and the HMAC is
883 not present, the SRH is omitted.
884 .sp
885
886 .B mode l2encap
887 - Encapsulate ingress L2 frame within an outer IPv6 header and SRH
888 .sp
889
890 .B mode l2encap.red
891 - Encapsulate ingress L2 frame within an outer IPv6 header and SRH
892 applying the reduced segment list. When there is only one segment
893 and the HMAC is not present, the SRH is omitted.
894 .sp
895
896 .I SEGMENTS
897 - List of comma-separated IPv6 addresses
898 .sp
899
900 .I KEYID
901 - Numerical value in decimal representation. See \fBip-sr\fR(8).
902 .in -2
903 .sp
904
905 .B seg6local
906 .in +2
907 .IR SEG6_ACTION " [ "
908 .IR SEG6_ACTION_PARAM " ] [ "
909 .BR count " ] "
910 - Operation to perform on matching packets. The optional \fBcount\fR
911 attribute is used to collect statistics on the processing of actions.
912 Three counters are implemented: 1) packets correctly processed;
913 2) bytes correctly processed; 3) packets that cause a processing error
914 (i.e., missing SID List, wrong SID List, etc). To retrieve the counters
915 related to an action use the \fB-s\fR flag in the \fBshow\fR command.
916 The following actions are currently supported (\fBLinux 4.14+ only\fR).
917 .in +2
918
919 .BR End " [ " flavors
920 .IR FLAVORS " ] "
921 - Regular SRv6 processing as intermediate segment endpoint.
922 This action only accepts packets with a non-zero Segments Left
923 value. Other matching packets are dropped. The presence of flavors
924 can change the regular processing of an End behavior according to
925 the user-provided Flavor operations and information carried in the packet.
926 See \fBFlavors parameters\fR section.
927
928 .B End.X nh6
929 .I NEXTHOP
930 .RB [ " flavors "
931 .IR FLAVORS " ] "
932 - Regular SRv6 processing as intermediate segment endpoint.
933 Additionally, forward processed packets to given next-hop.
934 This action only accepts packets with a non-zero Segments Left
935 value. Other matching packets are dropped. The presence of flavors
936 can change the regular processing of an End.X behavior according to
937 the user-provided Flavor operations and information carried in the packet.
938 See \fBFlavors parameters\fR section.
939
940
941 .B End.DX6 nh6
942 .I NEXTHOP
943 - Decapsulate inner IPv6 packet and forward it to the
944 specified next-hop. If the argument is set to ::, then
945 the next-hop is selected according to the local selection
946 rules. This action only accepts packets with either a zero Segments
947 Left value or no SRH at all, and an inner IPv6 packet. Other
948 matching packets are dropped.
949
950 .BR End.DT6 " { " table " | " vrftable " } "
951 .I TABLEID
952 - Decapsulate the inner IPv6 packet and forward it according to the
953 specified lookup table.
954 .I TABLEID
955 is either a number or a string from
956 .BR /usr/share/iproute2/rt_tables " or " /etc/iproute2/rt_tables
957 (has precedence if exists).
958 If
959 .B vrftable
960 is used, the argument must be a VRF device associated with
961 the table id. Moreover, the VRF table associated with the
962 table id must be configured with the VRF strict mode turned
963 on (net.vrf.strict_mode=1). This action only accepts packets
964 with either a zero Segments Left value or no SRH at all,
965 and an inner IPv6 packet. Other matching packets are dropped.
966
967 .B End.DT4 vrftable
968 .I TABLEID
969 - Decapsulate the inner IPv4 packet and forward it according to the
970 specified lookup table.
971 .I TABLEID
972 is either a number or a string from
973 .BR /usr/share/iproute2/rt_tables " or " /etc/iproute2/rt_tables
974 (has precedence if exists).
975 The argument must be a VRF device associated with the table id.
976 Moreover, the VRF table associated with the table id must be configured
977 with the VRF strict mode turned on (net.vrf.strict_mode=1). This action
978 only accepts packets with either a zero Segments Left value or no SRH
979 at all, and an inner IPv4 packet. Other matching packets are dropped.
980
981 .B End.DT46 vrftable
982 .I TABLEID
983 - Decapsulate the inner IPv4 or IPv6 packet and forward it according
984 to the specified lookup table.
985 .I TABLEID
986 is either a number or a string from
987 .BR /usr/share/iproute2/rt_tables " or " /etc/iproute2/rt_tables
988 (has precedence if exists).
989 The argument must be a VRF device associated with the table id.
990 Moreover, the VRF table associated with the table id must be configured
991 with the VRF strict mode turned on (net.vrf.strict_mode=1). This action
992 only accepts packets with either a zero Segments Left value or no SRH
993 at all, and an inner IPv4 or IPv6 packet. Other matching packets are
994 dropped.
995
996 .B End.B6 srh segs
997 .IR SEGMENTS " [ "
998 .B hmac
999 .IR KEYID " ] "
1000 - Insert the specified SRH immediately after the IPv6 header,
1001 update the DA with the first segment of the newly inserted SRH,
1002 then forward the resulting packet. The original SRH is not
1003 modified. This action only accepts packets with a non-zero
1004 Segments Left value. Other matching packets are dropped.
1005
1006 .B End.B6.Encaps srh segs
1007 .IR SEGMENTS " [ "
1008 .B hmac
1009 .IR KEYID " ] "
1010 - Regular SRv6 processing as intermediate segment endpoint.
1011 Additionally, encapsulate the matching packet within an outer IPv6 header
1012 followed by the specified SRH. The destination address of the outer IPv6
1013 header is set to the first segment of the new SRH. The source
1014 address is set as described in \fBip-sr\fR(8).
1015
1016 .B Flavors parameters
1017
1018 The flavors represent additional operations that can modify or extend a
1019 subset of the existing behaviors.
1020 .in +2
1021
1022 .B flavors
1023 .IR OPERATION "[," OPERATION "] [" ATTRIBUTES "]"
1024 .in +2
1025
1026 .IR OPERATION " := { "
1027 .BR psp " | "
1028 .BR usp " | "
1029 .BR usd " | "
1030 .BR next-csid " }"
1031
1032 .IR ATTRIBUTES " := {"
1033 .IR "KEY VALUE" " } ["
1034 .IR ATTRIBUTES " ]"
1035
1036 .IR KEY " := { "
1037 .BR lblen " | "
1038 .BR nflen " } "
1039 .in -2
1040
1041 .B psp
1042 - The Penultimate Segment Pop (PSP) copies the last SID from the SID List
1043 (carried by the outermost SRH) into the IPv6 Destination Address (DA) and
1044 removes (i.e. pops) the SRH from the IPv6 header.
1045 The PSP operation takes place only at a penultimate SR Segment Endpoint node
1046 (e.g., the Segment Left must be one) and does not happen at non-penultimate
1047 endpoint nodes. This flavor is currently only supported by End behavior.
1048
1049 .B usp
1050 - Ultimate Segment Pop of the SRH (not yet supported in kernel)
1051
1052 .B usd
1053 - Ultimate Segment Decapsulation (not yet supported in kernel)
1054
1055 .B next-csid
1056 - The NEXT-C-SID mechanism offers the possibility of encoding
1057 several SRv6 segments within a single 128 bit SID address. The NEXT-C-SID
1058 flavor can be configured to support user-provided Locator-Block and
1059 Locator-Node Function lengths. If Locator-Block and/or Locator-Node Function
1060 lengths are not provided by the user during configuration of an SRv6 End
1061 behavior instance with NEXT-C-SID flavor, the default value is 32-bit for
1062 Locator-Block and 16-bit for Locator-Node Function.
1063
1064 .BI lblen " VALUE "
1065 - defines the Locator-Block length for NEXT-C-SID flavor.
1066 The Locator-Block length must be greater than 0 and evenly divisible by 8. This
1067 attribute can be used only with NEXT-C-SID flavor.
1068
1069 .BI nflen " VALUE "
1070 - defines the Locator-Node Function length for NEXT-C-SID
1071 flavors. The Locator-Node Function length must be greater than 0 and evenly
1072 divisible by 8. This attribute can be used only with NEXT-C-SID flavor.
1073 .in -4
1074
1075 .B ioam6
1076 .in +2
1077 .B freq K/N
1078 - Inject IOAM in K packets every N packets (default is 1/1).
1079
1080 .B mode inline
1081 - Directly insert IOAM after IPv6 header (default mode).
1082 .sp
1083
1084 .B mode encap
1085 - Encapsulate packet in an outer IPv6 header with IOAM.
1086 .sp
1087
1088 .B mode auto
1089 - Automatically use inline mode for local packets and encap mode for in-transit
1090 packets.
1091 .sp
1092
1093 .B tunsrc
1094 .I ADDRESS
1095 - IPv6 address of the tunnel source (outer header), not used with inline mode.
1096 It is optional: if not provided, the tunnel source address is chosen
1097 automatically.
1098
1099 .B tundst
1100 .I ADDRESS
1101 - IPv6 address of the tunnel destination (outer header), not used with inline
1102 mode.
1103
1104 .B type
1105 .I IOAM6_TRACE_TYPE
1106 - List of IOAM data required in the trace, represented by a bitfield (24 bits).
1107 .sp
1108
1109 .B ns
1110 .I IOAM6_NAMESPACE
1111 - Numerical value to represent an IOAM namespace. See \fBip-ioam\fR(8).
1112 .sp
1113
1114 .B size
1115 .I IOAM6_TRACE_SIZE
1116 - Size, in octets, of the pre-allocated trace data block.
1117 .in -2
1118
1119 .B xfrm
1120 .in +2
1121 .B if_id
1122 .I IF_ID
1123 .B " [ link_dev
1124 .IR LINK_DEV " ] "
1125 .in -4
1126
1127 .in -8
1128
1129 .TP
1130 .BI expires " TIME " "(Linux 4.4+ only)"
1131 the route will be deleted after the expires time.
1132 .B Only
1133 support IPv6 at present.
1134
1135 .TP
1136 .BR ttl-propagate " { " enabled " | " disabled " } "
1137 Control whether TTL should be propagated from any encap into the
1138 un-encapsulated packet, overriding any global configuration. Only
1139 supported for MPLS at present.
1140 .RE
1141
1142 .TP
1143 ip route delete
1144 delete route
1145 .RS
1146 .B ip route del
1147 has the same arguments as
1148 .BR "ip route add" ,
1149 but their semantics are a bit different.
1150
1151 Key values
1152 .RB "(" to ", " tos ", " preference " and " table ")"
1153 select the route to delete. If optional attributes are present,
1154 .B ip
1155 verifies that they coincide with the attributes of the route to delete.
1156 If no route with the given key and attributes was found,
1157 .B ip route del
1158 fails.
1159 .RE
1160
1161 .TP
1162 ip route show
1163 list routes
1164 .RS
1165 the command displays the contents of the routing tables or the route(s)
1166 selected by some criteria.
1167
1168 .TP
1169 .BI to " SELECTOR " (default)
1170 only select routes from the given range of destinations.
1171 .I SELECTOR
1172 consists of an optional modifier
1173 .RB "(" root ", " match " or " exact ")"
1174 and a prefix.
1175 .BI root " PREFIX"
1176 selects routes with prefixes not shorter than
1177 .IR PREFIX "."
1178 F.e.
1179 .BI root " 0/0"
1180 selects the entire routing table.
1181 .BI match " PREFIX"
1182 selects routes with prefixes not longer than
1183 .IR PREFIX "."
1184 F.e.
1185 .BI match " 10.0/16"
1186 selects
1187 .IR 10.0/16 ","
1188 .IR 10/8 " and " 0/0 ,
1189 but it does not select
1190 .IR 10.1/16 " and " 10.0.0/24 .
1191 And
1192 .BI exact " PREFIX"
1193 (or just
1194 .IR PREFIX ")"
1195 selects routes with this exact prefix. If neither of these options
1196 are present,
1197 .B ip
1198 assumes
1199 .BI root " 0/0"
1200 i.e. it lists the entire table.
1201
1202 .TP
1203 .BI tos " TOS"
1204 .TP
1205 .BI dsfield " TOS"
1206 only select routes with the given TOS.
1207
1208 .TP
1209 .BI table " TABLEID"
1210 show the routes from this table(s). The default setting is to show table
1211 .BR main "."
1212 .I TABLEID
1213 may either be the ID of a real table or one of the special values:
1214 .sp
1215 .in +8
1216 .B all
1217 - list all of the tables.
1218 .sp
1219 .B cache
1220 - dump the routing cache.
1221 .in -8
1222
1223 .TP
1224 .BI vrf " NAME"
1225 show the routes for the table associated with the vrf name
1226
1227 .TP
1228 .B cloned
1229 .TP
1230 .B cached
1231 list cloned routes i.e. routes which were dynamically forked from
1232 other routes because some route attribute (f.e. MTU) was updated.
1233 Actually, it is equivalent to
1234 .BR "table cache" "."
1235
1236 .TP
1237 .BI from " SELECTOR"
1238 the same syntax as for
1239 .BR to ","
1240 but it binds the source address range rather than destinations.
1241 Note that the
1242 .B from
1243 option only works with cloned routes.
1244
1245 .TP
1246 .BI protocol " RTPROTO"
1247 only list routes of this protocol.
1248
1249 .TP
1250 .BI scope " SCOPE_VAL"
1251 only list routes with this scope.
1252
1253 .TP
1254 .BI type " TYPE"
1255 only list routes of this type.
1256
1257 .TP
1258 .BI dev " NAME"
1259 only list routes going via this device.
1260
1261 .TP
1262 .BI via " [ FAMILY ] PREFIX"
1263 only list routes going via the nexthop routers selected by
1264 .IR PREFIX "."
1265
1266 .TP
1267 .BI src " PREFIX"
1268 only list routes with preferred source addresses selected
1269 by
1270 .IR PREFIX "."
1271
1272 .TP
1273 .BI realm " REALMID"
1274 .TP
1275 .BI realms " FROMREALM/TOREALM"
1276 only list routes with these realms.
1277 .RE
1278
1279 .TP
1280 ip route flush
1281 flush routing tables
1282 .RS
1283 this command flushes routes selected by some criteria.
1284
1285 .sp
1286 The arguments have the same syntax and semantics as the arguments of
1287 .BR "ip route show" ,
1288 but routing tables are not listed but purged. The only difference is
1289 the default action:
1290 .B show
1291 dumps all the IP main routing table but
1292 .B flush
1293 prints the helper page.
1294
1295 .sp
1296 With the
1297 .B -statistics
1298 option, the command becomes verbose. It prints out the number of
1299 deleted routes and the number of rounds made to flush the routing
1300 table. If the option is given
1301 twice,
1302 .B ip route flush
1303 also dumps all the deleted routes in the format described in the
1304 previous subsection.
1305 .RE
1306
1307 .TP
1308 ip route get
1309 get a single route
1310 .RS
1311 this command gets a single route to a destination and prints its
1312 contents exactly as the kernel sees it.
1313
1314 .TP
1315 .BI fibmatch
1316 Return full fib lookup matched route. Default is to return the resolved
1317 dst entry
1318
1319 .TP
1320 .BI to " ADDRESS " (default)
1321 the destination address.
1322
1323 .TP
1324 .BI from " ADDRESS"
1325 the source address.
1326
1327 .TP
1328 .BI tos " TOS"
1329 .TP
1330 .BI dsfield " TOS"
1331 the Type Of Service.
1332
1333 .TP
1334 .BI iif " NAME"
1335 the device from which this packet is expected to arrive.
1336
1337 .TP
1338 .BI oif " NAME"
1339 force the output device on which this packet will be routed.
1340
1341 .TP
1342 .BI mark " MARK"
1343 the firewall mark
1344 .RB ( "fwmark" )
1345
1346 .TP
1347 .BI vrf " NAME"
1348 force the vrf device on which this packet will be routed.
1349
1350 .TP
1351 .BI ipproto " PROTOCOL"
1352 ip protocol as seen by the route lookup
1353
1354 .TP
1355 .BI sport " NUMBER"
1356 source port as seen by the route lookup
1357
1358 .TP
1359 .BI dport " NUMBER"
1360 destination port as seen by the route lookup
1361
1362 .TP
1363 .B connected
1364 if no source address
1365 .RB "(option " from ")"
1366 was given, relookup the route with the source set to the preferred
1367 address received from the first lookup.
1368 If policy routing is used, it may be a different route.
1369
1370 .TP
1371 .BI flowlabel " FLOWLABEL"
1372 ipv6 flow label as seen by the route lookup
1373
1374 .P
1375 Note that this operation is not equivalent to
1376 .BR "ip route show" .
1377 .B show
1378 shows existing routes.
1379 .B get
1380 resolves them and creates new clones if necessary. Essentially,
1381 .B get
1382 is equivalent to sending a packet along this path.
1383 If the
1384 .B iif
1385 argument is not given, the kernel creates a route
1386 to output packets towards the requested destination.
1387 This is equivalent to pinging the destination
1388 with a subsequent
1389 .BR "ip route ls cache" ,
1390 however, no packets are actually sent. With the
1391 .B iif
1392 argument, the kernel pretends that a packet arrived from this interface
1393 and searches for a path to forward the packet.
1394 .RE
1395
1396 .TP
1397 ip route save
1398 save routing table information to stdout
1399 .RS
1400 This command behaves like
1401 .BR "ip route show"
1402 except that the output is raw data suitable for passing to
1403 .BR "ip route restore" .
1404 .RE
1405
1406 .TP
1407 ip route restore
1408 restore routing table information from stdin
1409 .RS
1410 This command expects to read a data stream as returned from
1411 .BR "ip route save" .
1412 It will attempt to restore the routing table information exactly as
1413 it was at the time of the save, so any translation of information
1414 in the stream (such as device indexes) must be done first. Any existing
1415 routes are left unchanged. Any routes specified in the data stream that
1416 already exist in the table will be ignored.
1417 .RE
1418
1419 .SH NOTES
1420 Starting with Linux kernel version 3.6, there is no routing cache for IPv4
1421 anymore. Hence
1422 .B "ip route show cached"
1423 will never print any entries on systems with this or newer kernel versions.
1424
1425 .SH EXAMPLES
1426 .PP
1427 ip ro
1428 .RS 4
1429 Show all route entries in the kernel.
1430 .RE
1431 .PP
1432 ip route add default via 192.168.1.1 dev eth0
1433 .RS 4
1434 Adds a default route (for all addresses) via the local gateway 192.168.1.1 that can
1435 be reached on device eth0.
1436 .RE
1437 .PP
1438 ip route add 10.1.1.0/30 encap mpls 200/300 via 10.1.1.1 dev eth0
1439 .RS 4
1440 Adds an ipv4 route with mpls encapsulation attributes attached to it.
1441 .RE
1442 .PP
1443 ip -6 route add 2001:db8:1::/64 encap seg6 mode encap segs 2001:db8:42::1,2001:db8:ffff::2 dev eth0
1444 .RS 4
1445 Adds an IPv6 route with SRv6 encapsulation and two segments attached.
1446 .RE
1447 .PP
1448 ip -6 route add 2001:db8:1::/64 encap seg6local action End.DT46 vrftable 100 dev vrf100
1449 .RS 4
1450 Adds an IPv6 route with SRv6 decapsulation and forward with lookup in VRF table.
1451 .RE
1452 .PP
1453 ip -6 route add 2001:db8:1::/64 encap seg6local action End flavors psp dev eth0
1454 .RS 4
1455 Adds an IPv6 route with SRv6 End behavior with psp flavor enabled.
1456 .RE
1457 .PP
1458 ip -6 route add 2001:db8:1::/64 encap seg6local action End flavors next-csid dev eth0
1459 .RS 4
1460 Adds an IPv6 route with SRv6 End behavior with next-csid flavor enabled.
1461 .RE
1462 .PP
1463 ip -6 route add 2001:db8:1::/64 encap seg6local action End flavors next-csid lblen 48 nflen 16 dev eth0
1464 .RS 4
1465 Adds an IPv6 route with SRv6 End behavior with next-csid flavor enabled and user-provided Locator-Block and Locator-Node Function lengths.
1466 .RE
1467 .PP
1468 ip -6 route add 2001:db8:1::/64 encap ioam6 freq 2/5 mode encap tundst 2001:db8:42::1 trace prealloc type 0x800000 ns 1 size 12 dev eth0
1469 .RS 4
1470 Adds an IPv6 route with an IOAM Pre-allocated Trace encapsulation (ip6ip6) that only includes the hop limit and the node id, configured for the IOAM namespace 1 and a pre-allocated data block of 12 octets (will be injected in 2 packets every 5 packets).
1471 .RE
1472 .PP
1473 ip route add 10.1.1.0/30 nhid 10
1474 .RS 4
1475 Adds an ipv4 route using nexthop object with id 10.
1476 .RE
1477 .SH SEE ALSO
1478 .br
1479 .BR ip (8)
1480
1481 .SH AUTHOR
1482 Original Manpage by Michail Litvak <[email protected]>