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