1IP-ROUTE(8)                          Linux                         IP-ROUTE(8)
2
3
4

NAME

6       ip-route - routing table management
7

SYNOPSIS

9       ip [ ip-OPTIONS ] route  { COMMAND | help }
10
11
12       ip route { show | flush } SELECTOR
13
14       ip route save SELECTOR
15
16       ip route restore
17
18       ip route get ROUTE_GET_FLAGS ADDRESS [ from ADDRESS iif STRING  ] [ oif
19               STRING ] [ mark MARK ] [ tos TOS ] [ vrf NAME ] [ ipproto PRO‐
20               TOCOL ] [ sport NUMBER ] [ dport NUMBER ]
21
22       ip route { add | del | change | append | replace } ROUTE
23
24       SELECTOR := [ root PREFIX ] [ match PREFIX ] [ exact PREFIX ] [ table
25               TABLE_ID ] [ vrf NAME ] [ proto RTPROTO ] [ type TYPE ] [ scope
26               SCOPE ]
27
28       ROUTE := NODE_SPEC [ INFO_SPEC ]
29
30       NODE_SPEC := [ TYPE ] PREFIX [ tos TOS ] [ table TABLE_ID ] [ proto RT‐
31               PROTO ] [ scope SCOPE ] [ metric METRIC ] [ ttl-propagate { en‐
32               abled | disabled } ]
33
34       INFO_SPEC := { NH | nhid ID } OPTIONS FLAGS [ nexthop NH ] ...
35
36       NH := [ encap ENCAP ] [ via [ FAMILY ] ADDRESS ] [ dev STRING ] [
37               weight NUMBER ] NHFLAGS
38
39       FAMILY := [ inet | inet6 | mpls | bridge | link ]
40
41       OPTIONS := FLAGS [ mtu NUMBER ] [ advmss NUMBER ] [ as [ to ] ADDRESS ]
42               rtt TIME ] [ rttvar TIME ] [ reordering NUMBER ] [ window NUM‐
43               BER ] [ cwnd NUMBER ] [ ssthresh NUMBER ] [ realms REALM ] [
44               rto_min TIME ] [ initcwnd NUMBER ] [ initrwnd NUMBER ] [ fea‐
45               tures FEATURES ] [ quickack BOOL ] [ congctl NAME ] [ pref PREF
46               ] [ expires TIME ] [ fastopen_no_cookie BOOL ]
47
48       TYPE := [ unicast | local | broadcast | multicast | throw | unreachable
49               | prohibit | blackhole | nat ]
50
51       TABLE_ID := [ local| main | default | all | NUMBER ]
52
53       SCOPE := [ host | link | global | NUMBER ]
54
55       NHFLAGS := [ onlink | pervasive ]
56
57       RTPROTO := [ kernel | boot | static | NUMBER ]
58
59       FEATURES := [ ecn | ]
60
61       PREF := [ low | medium | high ]
62
63       ENCAP := [ ENCAP_MPLS | ENCAP_IP | ENCAP_BPF | ENCAP_SEG6 | EN‐
64               CAP_SEG6LOCAL | ENCAP_IOAM6 ]
65
66       ENCAP_MPLS := mpls [ LABEL ] [ ttl TTL ]
67
68       ENCAP_IP := ip id TUNNEL_ID dst REMOTE_IP [ src SRC ] [ tos TOS ] [ ttl
69               TTL ]
70
71       ENCAP_BPF := bpf [ in PROG ] [ out PROG ] [ xmit PROG ] [ headroom SIZE
72               ]
73
74       ENCAP_SEG6 := seg6 mode [ encap | inline | l2encap ] segs SEGMENTS [
75               hmac KEYID ]
76
77       ENCAP_SEG6LOCAL := seg6local action SEG6_ACTION [ SEG6_ACTION_PARAM ] [
78               count ]
79
80       ENCAP_IOAM6 := ioam6 [ freq K/N ] mode [ inline | encap | auto ] [
81               tundst ADDRESS ] trace prealloc type IOAM6_TRACE_TYPE ns
82               IOAM6_NAMESPACE size IOAM6_TRACE_SIZE
83
84       ROUTE_GET_FLAGS :=  [ fibmatch  ]
85
86

DESCRIPTION

88       ip route is used to manipulate entries in the kernel routing tables.
89
90       Route types:
91
92               unicast - the route entry describes real paths to the destina‐
93               tions covered by the route prefix.
94
95
96               unreachable - these destinations are unreachable. Packets are
97               discarded and the ICMP message host unreachable is generated.
98               The local senders get an EHOSTUNREACH error.
99
100
101               blackhole - these destinations are unreachable. Packets are
102               discarded silently.  The local senders get an EINVAL error.
103
104
105               prohibit - these destinations are unreachable. Packets are dis‐
106               carded and the ICMP message communication administratively pro‐
107               hibited is generated. The local senders get an EACCES error.
108
109
110               local - the destinations are assigned to this host. The packets
111               are looped back and delivered locally.
112
113
114               broadcast - the destinations are broadcast addresses. The pack‐
115               ets are sent as link broadcasts.
116
117
118               throw - a special control route used together with policy
119               rules. If such a route is selected, lookup in this table is
120               terminated pretending that no route was found. Without policy
121               routing it is equivalent to the absence of the route in the
122               routing table. The packets are dropped and the ICMP message net
123               unreachable is generated. The local senders get an ENETUNREACH
124               error.
125
126
127               nat - a special NAT route. Destinations covered by the prefix
128               are considered to be dummy (or external) addresses which re‐
129               quire translation to real (or internal) ones before forwarding.
130               The addresses to translate to are selected with the attribute
131               via.  Warning: Route NAT is no longer supported in Linux 2.6.
132
133
134               anycast - not implemented the destinations are anycast ad‐
135               dresses assigned to this host. They are mainly equivalent to
136               local with one difference: such addresses are invalid when used
137               as the source address of any packet.
138
139
140               multicast - a special type used for multicast routing. It is
141               not present in normal routing tables.
142
143
144       Route tables: Linux-2.x can pack routes into several routing tables
145       identified by a number in the range from 1 to 2^32-1 or by name from
146       the file /etc/iproute2/rt_tables By default all normal routes are in‐
147       serted into the main table (ID 254) and the kernel only uses this table
148       when calculating routes.  Values (0, 253, 254, and 255) are reserved
149       for built-in use.
150
151
152       Actually, one other table always exists, which is invisible but even
153       more important. It is the local table (ID 255). This table consists of
154       routes for local and broadcast addresses. The kernel maintains this ta‐
155       ble automatically and the administrator usually need not modify it or
156       even look at it.
157
158       The multiple routing tables enter the game when policy routing is used.
159
160
161       ip route add
162              add new route
163
164       ip route change
165              change route
166
167       ip route replace
168              change or add new one
169
170              to TYPE PREFIX (default)
171                     the destination prefix of the route. If TYPE is omitted,
172                     ip assumes type unicast.  Other values of TYPE are listed
173                     above.  PREFIX is an IP or IPv6 address optionally fol‐
174                     lowed by a slash and the prefix length. If the length of
175                     the prefix is missing, ip assumes a full-length host
176                     route. There is also a special PREFIX default - which is
177                     equivalent to IP 0/0 or to IPv6 ::/0.
178
179
180              tos TOS
181
182              dsfield TOS
183                     the Type Of Service (TOS) key. This key has no associated
184                     mask and the longest match is understood as: First, com‐
185                     pare the TOS of the route and of the packet. If they are
186                     not equal, then the packet may still match a route with a
187                     zero TOS.  TOS is either an 8 bit hexadecimal number or
188                     an identifier from /etc/iproute2/rt_dsfield.
189
190
191              metric NUMBER
192
193              preference NUMBER
194                     the preference value of the route.  NUMBER is an arbi‐
195                     trary 32bit number, where routes with lower values are
196                     preferred.
197
198
199              table TABLEID
200                     the table to add this route to.  TABLEID may be a number
201                     or a string from the file /etc/iproute2/rt_tables.  If
202                     this parameter is omitted, ip assumes the main table,
203                     with the exception of local, broadcast and nat routes,
204                     which are put into the local table by default.
205
206
207              vrf NAME
208                     the vrf name to add this route to. Implicitly means the
209                     table associated with the VRF.
210
211
212              dev NAME
213                     the output device name.
214
215
216              via [ FAMILY ] ADDRESS
217                     the address of the nexthop router, in the address family
218                     FAMILY.  Actually, the sense of this field depends on the
219                     route type.  For normal unicast routes it is either the
220                     true next hop router or, if it is a direct route in‐
221                     stalled in BSD compatibility mode, it can be a local ad‐
222                     dress of the interface. For NAT routes it is the first
223                     address of the block of translated IP destinations.
224
225
226              src ADDRESS
227                     the source address to prefer when sending to the destina‐
228                     tions covered by the route prefix.
229
230
231              realm REALMID
232                     the realm to which this route is assigned.  REALMID may
233                     be a number or a string from the file
234                     /etc/iproute2/rt_realms.
235
236
237              mtu MTU
238
239              mtu lock MTU
240                     the MTU along the path to the destination. If the modi‐
241                     fier lock is not used, the MTU may be updated by the ker‐
242                     nel due to Path MTU Discovery. If the modifier lock is
243                     used, no path MTU discovery will be tried, all packets
244                     will be sent without the DF bit in IPv4 case or frag‐
245                     mented to MTU for IPv6.
246
247
248              window NUMBER
249                     the maximal window for TCP to advertise to these destina‐
250                     tions, measured in bytes. It limits maximal data bursts
251                     that our TCP peers are allowed to send to us.
252
253
254              rtt TIME
255                     the initial RTT ('Round Trip Time') estimate. If no suf‐
256                     fix is specified the units are raw values passed directly
257                     to the routing code to maintain compatibility with previ‐
258                     ous releases.  Otherwise if a suffix of s, sec or secs is
259                     used to specify seconds and ms, msec or msecs to specify
260                     milliseconds.
261
262
263
264              rttvar TIME (Linux 2.3.15+ only)
265                     the initial RTT variance estimate. Values are specified
266                     as with rtt above.
267
268
269              rto_min TIME (Linux 2.6.23+ only)
270                     the minimum TCP Retransmission TimeOut to use when commu‐
271                     nicating with this destination. Values are specified as
272                     with rtt above.
273
274
275              ssthresh NUMBER (Linux 2.3.15+ only)
276                     an estimate for the initial slow start threshold.
277
278
279              cwnd NUMBER (Linux 2.3.15+ only)
280                     the clamp for congestion window. It is ignored if the
281                     lock flag is not used.
282
283
284              initcwnd NUMBER (Linux 2.5.70+ only)
285                     the initial congestion window size for connections to
286                     this destination.  Actual window size is this value mul‐
287                     tiplied by the MSS (``Maximal Segment Size'') for same
288                     connection. The default is zero, meaning to use the val‐
289                     ues specified in RFC2414.
290
291
292              initrwnd NUMBER (Linux 2.6.33+ only)
293                     the initial receive window size for connections to this
294                     destination.  Actual window size is this value multiplied
295                     by the MSS of the connection.  The default value is zero,
296                     meaning to use Slow Start value.
297
298
299              features FEATURES (Linux3.18+only)
300                     Enable or disable per-route features. Only available fea‐
301                     ture at this time is ecn to enable explicit congestion
302                     notification when initiating connections to the given
303                     destination network.  When responding to a connection re‐
304                     quest from the given network, ecn will also be used even
305                     if the net.ipv4.tcp_ecn sysctl is set to 0.
306
307
308              quickack BOOL (Linux 3.11+ only)
309                     Enable or disable quick ack for connections to this des‐
310                     tination.
311
312
313              fastopen_no_cookie BOOL (Linux 4.15+ only)
314                     Enable TCP Fastopen without a cookie for connections to
315                     this destination.
316
317
318              congctl NAME (Linux 3.20+ only)
319
320              congctl lock NAME (Linux 3.20+ only)
321                     Sets a specific TCP congestion control algorithm only for
322                     a given destination.  If not specified, Linux keeps the
323                     current global default TCP congestion control algorithm,
324                     or the one set from the application. If the modifier lock
325                     is not used, an application may nevertheless overwrite
326                     the suggested congestion control algorithm for that des‐
327                     tination. If the modifier lock is used, then an applica‐
328                     tion is not allowed to overwrite the specified congestion
329                     control algorithm for that destination, thus it will be
330                     enforced/guaranteed to use the proposed algorithm.
331
332
333              advmss NUMBER (Linux 2.3.15+ only)
334                     the MSS ('Maximal Segment Size') to advertise to these
335                     destinations when establishing TCP connections. If it is
336                     not given, Linux uses a default value calculated from the
337                     first hop device MTU.  (If the path to these destination
338                     is asymmetric, this guess may be wrong.)
339
340
341              reordering NUMBER (Linux 2.3.15+ only)
342                     Maximal reordering on the path to this destination.  If
343                     it is not given, Linux uses the value selected with
344                     sysctl variable net/ipv4/tcp_reordering.
345
346
347              nexthop NEXTHOP
348                     the nexthop of a multipath route.  NEXTHOP is a complex
349                     value with its own syntax similar to the top level argu‐
350                     ment lists:
351
352                             via [ FAMILY ] ADDRESS - is the nexthop router.
353
354
355                             dev NAME - is the output device.
356
357
358                             weight NUMBER - is a weight for this element of a
359                             multipath route reflecting its relative bandwidth
360                             or quality.
361
362                     The internal buffer used in iproute2 limits the maximum
363                     number of nexthops that may be specified in one go. If
364                     only ADDRESS is given, the current buffer size allows for
365                     144 IPv6 nexthops and 253 IPv4 ones. For IPv4, this ef‐
366                     fectively limits the number of nexthops possible per
367                     route. With IPv6, further nexthops may be appended to the
368                     same route via ip route append command.
369
370
371              scope SCOPE_VAL
372                     the scope of the destinations covered by the route pre‐
373                     fix.  SCOPE_VAL may be a number or a string from the file
374                     /etc/iproute2/rt_scopes.  If this parameter is omitted,
375                     ip assumes scope global for all gatewayed unicast routes,
376                     scope link for direct unicast and broadcast routes and
377                     scope host for local routes.
378
379
380              protocol RTPROTO
381                     the routing protocol identifier of this route.  RTPROTO
382                     may be a number or a string from the file
383                     /etc/iproute2/rt_protos.  If the routing protocol ID is
384                     not given, ip assumes protocol boot (i.e. it assumes the
385                     route was added by someone who doesn't understand what
386                     they are doing). Several protocol values have a fixed in‐
387                     terpretation.  Namely:
388
389                             redirect - the route was installed due to an ICMP
390                             redirect.
391
392
393                             kernel - the route was installed by the kernel
394                             during autoconfiguration.
395
396
397                             boot - the route was installed during the bootup
398                             sequence.  If a routing daemon starts, it will
399                             purge all of them.
400
401
402                             static - the route was installed by the adminis‐
403                             trator to override dynamic routing. Routing dae‐
404                             mon will respect them and, probably, even adver‐
405                             tise them to its peers.
406
407
408                             ra - the route was installed by Router Discovery
409                             protocol.
410
411
412                     The rest of the values are not reserved and the adminis‐
413                     trator is free to assign (or not to assign) protocol
414                     tags.
415
416
417              onlink pretend that the nexthop is directly attached to this
418                     link, even if it does not match any interface prefix.
419
420
421              pref PREF
422                     the IPv6 route preference.  PREF is a string specifying
423                     the route preference as defined in RFC4191 for Router
424                     Discovery messages. Namely:
425
426                             low - the route has a lowest priority
427
428
429                             medium - the route has a default priority
430
431
432                             high - the route has a highest priority
433
434
435
436              nhid ID
437                     use nexthop object with given id as nexthop specifica‐
438                     tion.
439
440
441              encap ENCAPTYPE ENCAPHDR
442                     attach tunnel encapsulation attributes to this route.
443
444                     ENCAPTYPE is a string specifying the supported encapsula‐
445                     tion type. Namely:
446
447                             mpls - encapsulation type MPLS
448
449                             ip - IP encapsulation (Geneve, GRE, VXLAN, ...)
450
451                             bpf - Execution of BPF program
452
453                             seg6 - encapsulation type IPv6 Segment Routing
454
455                             seg6local - local SRv6 segment processing
456
457                             ioam6 - encapsulation type IPv6 IOAM
458
459                     ENCAPHDR is a set of encapsulation attributes specific to
460                     the ENCAPTYPE.
461
462                             mpls
463                               MPLSLABEL - mpls label stack with labels sepa‐
464                               rated by /
465
466
467                               ttl TTL - TTL to use for MPLS header or 0 to
468                               inherit from IP header
469
470
471                             ip
472                               id TUNNEL_ID dst REMOTE_IP [ src SRC ] [ tos
473                               TOS ] [ ttl TTL ] [ key ] [ csum ] [ seq ]
474
475
476                             bpf
477                               in PROG - BPF program to execute for incoming
478                               packets
479
480
481                               out PROG - BPF program to execute for outgoing
482                               packets
483
484
485                               xmit PROG - BPF program to execute for trans‐
486                               mitted packets
487
488
489                               headroom SIZE - Size of header BPF program will
490                               attach (xmit)
491
492
493                             seg6
494                               mode inline - Directly insert Segment Routing
495                               Header after IPv6 header
496
497
498                               mode encap - Encapsulate packet in an outer
499                               IPv6 header with SRH
500
501
502                               mode l2encap - Encapsulate ingress L2 frame
503                               within an outer IPv6 header and SRH
504
505
506                               SEGMENTS - List of comma-separated IPv6 ad‐
507                               dresses
508
509
510                               KEYID - Numerical value in decimal representa‐
511                               tion. See ip-sr(8).
512
513
514                             seg6local
515                               SEG6_ACTION [ SEG6_ACTION_PARAM ] [ count ] -
516                               Operation to perform on matching packets. The
517                               optional count attribute is used to collect
518                               statistics on the processing of actions.  Three
519                               counters are implemented: 1) packets correctly
520                               processed; 2) bytes correctly processed; 3)
521                               packets that cause a processing error (i.e.,
522                               missing SID List, wrong SID List, etc). To re‐
523                               trieve the counters related to an action use
524                               the -s flag in the show command.  The following
525                               actions are currently supported (Linux 4.14+
526                               only).
527
528                                 End - Regular SRv6 processing as intermediate
529                                 segment endpoint.  This action only accepts
530                                 packets with a non-zero Segments Left value.
531                                 Other matching packets are dropped.
532
533                                 End.X nh6 NEXTHOP - Regular SRv6 processing
534                                 as intermediate segment endpoint.  Addition‐
535                                 ally, forward processed packets to given
536                                 next-hop.  This action only accepts packets
537                                 with a non-zero Segments Left value. Other
538                                 matching packets are dropped.
539
540                                 End.DX6 nh6 NEXTHOP - Decapsulate inner IPv6
541                                 packet and forward it to the specified next-
542                                 hop. If the argument is set to ::, then the
543                                 next-hop is selected according to the local
544                                 selection rules. This action only accepts
545                                 packets with either a zero Segments Left
546                                 value or no SRH at all, and an inner IPv6
547                                 packet. Other matching packets are dropped.
548
549                                 End.DT6 { table | vrftable } TABLEID - Decap‐
550                                 sulate the inner IPv6 packet and forward it
551                                 according to the specified lookup table.
552                                 TABLEID is either a number or a string from
553                                 the file /etc/iproute2/rt_tables.  If
554                                 vrftable is used, the argument must be a VRF
555                                 device associated with the table id. More‐
556                                 over, the VRF table associated with the table
557                                 id must be configured with the VRF strict
558                                 mode turned on (net.vrf.strict_mode=1). This
559                                 action only accepts packets with either a
560                                 zero Segments Left value or no SRH at all,
561                                 and an inner IPv6 packet. Other matching
562                                 packets are dropped.
563
564                                 End.DT4 vrftable TABLEID - Decapsulate the
565                                 inner IPv4 packet and forward it according to
566                                 the specified lookup table.  TABLEID is ei‐
567                                 ther a number or a string from the file
568                                 /etc/iproute2/rt_tables.  The argument must
569                                 be a VRF device associated with the table id.
570                                 Moreover, the VRF table associated with the
571                                 table id must be configured with the VRF
572                                 strict mode turned on
573                                 (net.vrf.strict_mode=1). This action only ac‐
574                                 cepts packets with either a zero Segments
575                                 Left value or no SRH at all, and an inner
576                                 IPv4 packet. Other matching packets are
577                                 dropped.
578
579                                 End.DT46 vrftable TABLEID - Decapsulate the
580                                 inner IPv4 or IPv6 packet and forward it ac‐
581                                 cording to the specified lookup table.
582                                 TABLEID is either a number or a string from
583                                 the file /etc/iproute2/rt_tables.  The argu‐
584                                 ment must be a VRF device associated with the
585                                 table id.  Moreover, the VRF table associated
586                                 with the table id must be configured with the
587                                 VRF strict mode turned on
588                                 (net.vrf.strict_mode=1). This action only ac‐
589                                 cepts packets with either a zero Segments
590                                 Left value or no SRH at all, and an inner
591                                 IPv4 or IPv6 packet. Other matching packets
592                                 are dropped.
593
594                                 End.B6 srh segs SEGMENTS [ hmac KEYID ] - In‐
595                                 sert the specified SRH immediately after the
596                                 IPv6 header, update the DA with the first
597                                 segment of the newly inserted SRH, then for‐
598                                 ward the resulting packet. The original SRH
599                                 is not modified. This action only accepts
600                                 packets with a non-zero Segments Left value.
601                                 Other matching packets are dropped.
602
603                                 End.B6.Encaps srh segs SEGMENTS [ hmac KEYID
604                                 ] - Regular SRv6 processing as intermediate
605                                 segment endpoint.  Additionally, encapsulate
606                                 the matching packet within an outer IPv6
607                                 header followed by the specified SRH. The
608                                 destination address of the outer IPv6 header
609                                 is set to the first segment of the new SRH.
610                                 The source address is set as described in ip-
611                                 sr(8).
612
613                               ioam6
614                                 freq K/N - Inject IOAM in K packets every N
615                                 packets (default is 1/1).
616
617                                 mode inline - Directly insert IOAM after IPv6
618                                 header (default mode).
619
620
621                                 mode encap - Encapsulate packet in an outer
622                                 IPv6 header with IOAM.
623
624
625                                 mode auto - Automatically use inline mode for
626                                 local packets and encap mode for in-transit
627                                 packets.
628
629
630                                 tundst ADDRESS - IPv6 address of the tunnel
631                                 destination (outer header), not used with in‐
632                                 line mode.
633
634                                 type IOAM6_TRACE_TYPE - List of IOAM data re‐
635                                 quired in the trace, represented by a bit‐
636                                 field (24 bits).
637
638
639                                 ns IOAM6_NAMESPACE - Numerical value to rep‐
640                                 resent an IOAM namespace. See ip-ioam(8).
641
642
643                                 size IOAM6_TRACE_SIZE - Size, in octets, of
644                                 the pre-allocated trace data block.
645
646
647
648              expires TIME (Linux 4.4+ only)
649                     the route will be deleted after the expires time.  Only
650                     support IPv6 at present.
651
652
653              ttl-propagate { enabled | disabled }
654                     Control whether TTL should be propagated from any encap
655                     into the un-encapsulated packet, overriding any global
656                     configuration. Only supported for MPLS at present.
657
658
659       ip route delete
660              delete route
661              ip route del has the same arguments as ip route add, but their
662              semantics are a bit different.
663
664              Key values (to, tos, preference and table) select the route to
665              delete. If optional attributes are present, ip verifies that
666              they coincide with the attributes of the route to delete.  If no
667              route with the given key and attributes was found, ip route del
668              fails.
669
670
671       ip route show
672              list routes
673              the command displays the contents of the routing tables or the
674              route(s) selected by some criteria.
675
676
677              to SELECTOR (default)
678                     only select routes from the given range of destinations.
679                     SELECTOR consists of an optional modifier (root, match or
680                     exact) and a prefix.  root PREFIX selects routes with
681                     prefixes not shorter than PREFIX.  F.e.  root 0/0 selects
682                     the entire routing table.  match PREFIX selects routes
683                     with prefixes not longer than PREFIX.  F.e.  match
684                     10.0/16 selects 10.0/16, 10/8 and 0/0, but it does not
685                     select 10.1/16 and 10.0.0/24.  And exact PREFIX (or just
686                     PREFIX) selects routes with this exact prefix. If neither
687                     of these options are present, ip assumes root 0/0 i.e. it
688                     lists the entire table.
689
690
691              tos TOS
692
693              dsfield TOS
694                     only select routes with the given TOS.
695
696
697              table TABLEID
698                     show the routes from this table(s). The default setting
699                     is to show table main.  TABLEID may either be the ID of a
700                     real table or one of the special values:
701
702                             all - list all of the tables.
703
704                             cache - dump the routing cache.
705
706
707              vrf NAME
708                     show the routes for the table associated with the vrf
709                     name
710
711
712              cloned
713
714              cached list cloned routes i.e. routes which were dynamically
715                     forked from other routes because some route attribute
716                     (f.e. MTU) was updated.  Actually, it is equivalent to
717                     table cache.
718
719
720              from SELECTOR
721                     the same syntax as for to, but it binds the source ad‐
722                     dress range rather than destinations.  Note that the from
723                     option only works with cloned routes.
724
725
726              protocol RTPROTO
727                     only list routes of this protocol.
728
729
730              scope SCOPE_VAL
731                     only list routes with this scope.
732
733
734              type TYPE
735                     only list routes of this type.
736
737
738              dev NAME
739                     only list routes going via this device.
740
741
742              via [ FAMILY ] PREFIX
743                     only list routes going via the nexthop routers selected
744                     by PREFIX.
745
746
747              src PREFIX
748                     only list routes with preferred source addresses selected
749                     by PREFIX.
750
751
752              realm REALMID
753
754              realms FROMREALM/TOREALM
755                     only list routes with these realms.
756
757
758       ip route flush
759              flush routing tables
760              this command flushes routes selected by some criteria.
761
762
763              The arguments have the same syntax and semantics as the argu‐
764              ments of ip route show, but routing tables are not listed but
765              purged. The only difference is the default action: show dumps
766              all the IP main routing table but flush prints the helper page.
767
768
769              With the -statistics option, the command becomes verbose. It
770              prints out the number of deleted routes and the number of rounds
771              made to flush the routing table. If the option is given twice,
772              ip route flush also dumps all the deleted routes in the format
773              described in the previous subsection.
774
775
776       ip route get
777              get a single route
778              this command gets a single route to a destination and prints its
779              contents exactly as the kernel sees it.
780
781
782              fibmatch
783                     Return full fib lookup matched route. Default is to re‐
784                     turn the resolved dst entry
785
786
787              to ADDRESS (default)
788                     the destination address.
789
790
791              from ADDRESS
792                     the source address.
793
794
795              tos TOS
796
797              dsfield TOS
798                     the Type Of Service.
799
800
801              iif NAME
802                     the device from which this packet is expected to arrive.
803
804
805              oif NAME
806                     force the output device on which this packet will be
807                     routed.
808
809
810              mark MARK
811                     the firewall mark (fwmark)
812
813
814              vrf NAME
815                     force the vrf device on which this packet will be routed.
816
817
818              ipproto PROTOCOL
819                     ip protocol as seen by the route lookup
820
821
822              sport NUMBER
823                     source port as seen by the route lookup
824
825
826              dport NUMBER
827                     destination port as seen by the route lookup
828
829
830              connected
831                     if no source address (option from) was given, relookup
832                     the route with the source set to the preferred address
833                     received from the first lookup.  If policy routing is
834                     used, it may be a different route.
835
836
837              Note that this operation is not equivalent to ip route show.
838              show shows existing routes.  get resolves them and creates new
839              clones if necessary. Essentially, get is equivalent to sending a
840              packet along this path.  If the iif argument is not given, the
841              kernel creates a route to output packets towards the requested
842              destination.  This is equivalent to pinging the destination with
843              a subsequent ip route ls cache, however, no packets are actually
844              sent. With the iif argument, the kernel pretends that a packet
845              arrived from this interface and searches for a path to forward
846              the packet.
847
848
849       ip route save
850              save routing table information to stdout
851              This command behaves like ip route show except that the output
852              is raw data suitable for passing to ip route restore.
853
854
855       ip route restore
856              restore routing table information from stdin
857              This command expects to read a data stream as returned from ip
858              route save.  It will attempt to restore the routing table infor‐
859              mation exactly as it was at the time of the save, so any trans‐
860              lation of information in the stream (such as device indexes)
861              must be done first. Any existing routes are left unchanged. Any
862              routes specified in the data stream that already exist in the
863              table will be ignored.
864
865

NOTES

867       Starting with Linux kernel version 3.6, there is no routing cache for
868       IPv4 anymore. Hence ip route show cached will never print any entries
869       on systems with this or newer kernel versions.
870
871

EXAMPLES

873       ip ro
874           Show all route entries in the kernel.
875
876       ip route add default via 192.168.1.1 dev eth0
877           Adds a default route (for all addresses) via the local gateway
878           192.168.1.1 that can be reached on device eth0.
879
880       ip route add 10.1.1.0/30 encap mpls 200/300 via 10.1.1.1 dev eth0
881           Adds an ipv4 route with mpls encapsulation attributes attached to
882           it.
883
884       ip -6 route add 2001:db8:1::/64 encap seg6 mode encap segs
885       2001:db8:42::1,2001:db8:ffff::2 dev eth0
886           Adds an IPv6 route with SRv6 encapsulation and two segments at‐
887           tached.
888
889       ip -6 route add 2001:db8:1::/64 encap seg6local action End.DT46
890       vrftable 100 dev vrf100
891           Adds an IPv6 route with SRv6 decapsulation and forward with lookup
892           in VRF table.
893
894       ip -6 route add 2001:db8:1::/64 encap ioam6 freq 2/5 mode encap tundst
895       2001:db8:42::1 trace prealloc type 0x800000 ns 1 size 12 dev eth0
896           Adds an IPv6 route with an IOAM Pre-allocated Trace encapsulation
897           (ip6ip6) that only includes the hop limit and the node id, config‐
898           ured for the IOAM namespace 1 and a pre-allocated data block of 12
899           octets (will be injected in 2 packets every 5 packets).
900
901       ip route add 10.1.1.0/30 nhid 10
902           Adds an ipv4 route using nexthop object with id 10.
903

SEE ALSO

905       ip(8)
906
907

AUTHOR

909       Original Manpage by Michail Litvak <mci@owl.openwall.com>
910
911
912
913iproute2                          13 Dec 2012                      IP-ROUTE(8)
Impressum