Debian Codegraph @

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