{
    "mode": "man",
    "parameter": "ip-route",
    "section": "8",
    "url": "https://www.chedong.com/phpMan.php/man/ip-route/8/json",
    "generated": "2026-08-13T18:58:33Z",
    "synopsis": "ip [ ip-OPTIONS ] route  { COMMAND | help }\nip route { show | flush } SELECTOR\nip route save SELECTOR",
    "sections": {
        "NAME": {
            "content": "ip-route - routing table management\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "ip [ ip-OPTIONS ] route  { COMMAND | help }\n\n\nip route { show | flush } SELECTOR\n\nip route save SELECTOR\n",
            "subsections": [
                {
                    "name": "ip route restore",
                    "content": "ip route get ROUTEGETFLAGS ADDRESS [ from ADDRESS iif STRING  ] [ oif STRING ] [ mark MARK\n] [ tos TOS ] [ vrf NAME ] [ ipproto PROTOCOL ] [ sport NUMBER ] [ dport NUMBER ]\n\nip route { add | del | change | append | replace } ROUTE\n\nSELECTOR := [ root PREFIX ] [ match PREFIX ] [ exact PREFIX ] [ table TABLEID ] [ vrf NAME ]\n[ proto RTPROTO ] [ type TYPE ] [ scope SCOPE ]\n\nROUTE := NODESPEC [ INFOSPEC ]\n\nNODESPEC := [ TYPE ] PREFIX [ tos TOS ] [ table TABLEID ] [ proto RTPROTO ] [ scope SCOPE ]\n[ metric METRIC ] [ ttl-propagate { enabled | disabled } ]\n\nINFOSPEC := { NH | nhid ID } OPTIONS FLAGS [ nexthop NH ] ...\n\nNH := [ encap ENCAP ] [ via [ FAMILY ] ADDRESS ] [ dev STRING ] [ weight NUMBER ] NHFLAGS\n\nFAMILY := [ inet | inet6 | mpls | bridge | link ]\n\nOPTIONS := FLAGS [ mtu NUMBER ] [ advmss NUMBER ] [ as [ to ] ADDRESS ] rtt TIME ] [ rttvar\nTIME ] [ reordering NUMBER ] [ window NUMBER ] [ cwnd NUMBER ] [ ssthresh NUMBER ] [\nrealms REALM ] [ rtomin TIME ] [ initcwnd NUMBER ] [ initrwnd NUMBER ] [ features\nFEATURES ] [ quickack BOOL ] [ congctl NAME ] [ pref PREF ] [ expires TIME ] [\nfastopennocookie BOOL ]\n\nTYPE := [ unicast | local | broadcast | multicast | throw | unreachable | prohibit | black‐\nhole | nat ]\n\nTABLEID := [ local| main | default | all | NUMBER ]\n\nSCOPE := [ host | link | global | NUMBER ]\n\nNHFLAGS := [ onlink | pervasive ]\n\nRTPROTO := [ kernel | boot | static | NUMBER ]\n\nFEATURES := [ ecn | ]\n\nPREF := [ low | medium | high ]\n\nENCAP := [ ENCAPMPLS | ENCAPIP | ENCAPBPF | ENCAPSEG6 | ENCAPSEG6LOCAL | ENCAPIOAM6 ]\n\nENCAPMPLS := mpls [ LABEL ] [ ttl TTL ]\n\nENCAPIP := ip id TUNNELID dst REMOTEIP [ src SRC ] [ tos TOS ] [ ttl TTL ]\n\nENCAPBPF := bpf [ in PROG ] [ out PROG ] [ xmit PROG ] [ headroom SIZE ]\n\nENCAPSEG6 := seg6 mode [ encap | encap.red | inline | l2encap | l2encap.red ] segs SEGMENTS\n[ hmac KEYID ]\n\nENCAPSEG6LOCAL := seg6local action SEG6ACTION [ SEG6ACTIONPARAM ] [ count ]\n\nENCAPIOAM6 := ioam6 [ freq K/N ] mode [ inline | encap | auto ] [ tundst ADDRESS ] trace\nprealloc type IOAM6TRACETYPE ns IOAM6NAMESPACE size IOAM6TRACESIZE\n\nROUTEGETFLAGS :=  [ fibmatch  ]\n\n"
                }
            ]
        },
        "DESCRIPTION": {
            "content": "ip route is used to manipulate entries in the kernel routing tables.\n",
            "subsections": [
                {
                    "name": "Route types:",
                    "content": "unicast - the route entry describes real paths to the destinations covered by the\nroute prefix.\n\n\nunreachable - these destinations are unreachable. Packets are discarded and the ICMP\nmessage host unreachable is generated.  The local senders get an EHOSTUNREACH error.\n\n\nblackhole - these destinations are unreachable. Packets are discarded silently.  The\nlocal senders get an EINVAL error.\n\n\nprohibit - these destinations are unreachable. Packets are discarded and the ICMP\nmessage communication administratively prohibited is generated. The local senders get\nan EACCES error.\n\n\nlocal - the destinations are assigned to this host. The packets are looped back and\ndelivered locally.\n\n\nbroadcast - the destinations are broadcast addresses. The packets are sent as link\nbroadcasts.\n\n\nthrow - a special control route used together with policy rules. If such a route is\nselected, lookup in this table is terminated pretending that no route was found.\nWithout policy routing it is equivalent to the absence of the route in the routing\ntable. The packets are dropped and the ICMP message net unreachable is generated. The\nlocal senders get an ENETUNREACH error.\n\n\nnat - a special NAT route. Destinations covered by the prefix are considered to be\ndummy (or external) addresses which require translation to real (or internal) ones\nbefore forwarding. The addresses to translate to are selected with the attribute via.\nWarning: Route NAT is no longer supported in Linux 2.6.\n\n\nanycast - not implemented the destinations are anycast addresses assigned to this\nhost. They are mainly equivalent to local with one difference: such addresses are in‐\nvalid when used as the source address of any packet.\n\n\nmulticast - a special type used for multicast routing. It is not present in normal\nrouting tables.\n\n\nRoute tables: Linux-2.x can pack routes into several routing tables identified by a number in\nthe range from 1 to 2^32-1 or by name from the file /etc/iproute2/rttables By default all\nnormal routes are inserted into the main table (ID 254) and the kernel only uses this table\nwhen calculating routes.  Values (0, 253, 254, and 255) are reserved for built-in use.\n\n\nActually, one other table always exists, which is invisible but even more important. It is\nthe local table (ID 255). This table consists of routes for local and broadcast addresses.\nThe kernel maintains this table automatically and the administrator usually need not modify\nit or even look at it.\n\nThe multiple routing tables enter the game when policy routing is used.\n\n\nip route add\nadd new route\n\nip route change\nchange route\n\nip route replace\nchange or add new one\n\nto TYPE PREFIX (default)\nthe  destination  prefix of the route. If TYPE is omitted, ip assumes type uni‐\ncast.  Other values of TYPE are listed above.  PREFIX is an IP or IPv6  address\noptionally followed by a slash and the prefix length. If the length of the pre‐\nfix  is  missing,  ip assumes a full-length host route. There is also a special\nPREFIX default - which is equivalent to IP 0/0 or to IPv6 ::/0.\n\n\ntos TOS\n\ndsfield TOS\nthe Type Of Service (TOS) key. This key has no associated mask and the  longest\nmatch  is understood as: First, compare the TOS of the route and of the packet.\nIf they are not equal, then the packet may still match a route with a zero TOS.\nTOS  is  either  an  8  bit  hexadecimal   number   or   an   identifier   from\n/etc/iproute2/rtdsfield.\n\n\nmetric NUMBER\n\npreference NUMBER\nthe  preference value of the route.  NUMBER is an arbitrary 32bit number, where\nroutes with lower values are preferred.\n\n\ntable TABLEID\nthe table to add this route to.  TABLEID may be a number or a string  from  the\nfile  /etc/iproute2/rttables.   If  this  parameter is omitted, ip assumes the\nmain table, with the exception of local, broadcast and nat  routes,  which  are\nput into the local table by default.\n\n\nvrf NAME\nthe  vrf  name to add this route to. Implicitly means the table associated with\nthe VRF.\n\n\ndev NAME\nthe output device name.\n\n\nvia [ FAMILY ] ADDRESS\nthe address of the nexthop router, in the address family FAMILY.  Actually, the\nsense of this field depends on the route type.  For normal unicast routes it is\neither the true next hop router or, if it is a direct route  installed  in  BSD\ncompatibility  mode, it can be a local address of the interface. For NAT routes\nit is the first address of the block of translated IP destinations.\n\n\nsrc ADDRESS\nthe source address to prefer when sending to the destinations  covered  by  the\nroute prefix.\n\n\nrealm REALMID\nthe realm to which this route is assigned.  REALMID may be a number or a string\nfrom the file /etc/iproute2/rtrealms.\n\n\nmtu MTU\n\nmtu lock MTU\nthe  MTU  along  the path to the destination. If the modifier lock is not used,\nthe MTU may be updated by the kernel due to Path MTU Discovery. If the modifier\nlock is used, no path MTU discovery will be tried, all  packets  will  be  sent\nwithout the DF bit in IPv4 case or fragmented to MTU for IPv6.\n\n\nwindow NUMBER\nthe  maximal  window  for  TCP  to advertise to these destinations, measured in\nbytes. It limits maximal data bursts that our TCP peers are allowed to send  to\nus.\n\n\nrtt TIME\nthe  initial  RTT  ('Round  Trip Time') estimate. If no suffix is specified the\nunits are raw values passed directly to the routing code to  maintain  compati‐\nbility with previous releases.  Otherwise if a suffix of s, sec or secs is used\nto specify seconds and ms, msec or msecs to specify milliseconds.\n\n\n\nrttvar TIME (Linux 2.3.15+ only)\nthe initial RTT variance estimate. Values are specified as with rtt above.\n\n\nrtomin TIME (Linux 2.6.23+ only)\nthe minimum TCP Retransmission TimeOut to use when communicating with this des‐\ntination. Values are specified as with rtt above.\n\n\nssthresh NUMBER (Linux 2.3.15+ only)\nan estimate for the initial slow start threshold.\n\n\ncwnd NUMBER (Linux 2.3.15+ only)\nthe clamp for congestion window. It is ignored if the lock flag is not used.\n\n\ninitcwnd NUMBER (Linux 2.5.70+ only)\nthe initial congestion window size for connections to this destination.  Actual\nwindow  size is this value multiplied by the MSS (``Maximal Segment Size'') for\nsame connection. The default is zero, meaning to use the  values  specified  in\nRFC2414.\n\n\ninitrwnd NUMBER (Linux 2.6.33+ only)\nthe  initial  receive  window size for connections to this destination.  Actual\nwindow size is this value multiplied by the MSS of the connection.  The default\nvalue is zero, meaning to use Slow Start value.\n\n\nfeatures FEATURES (Linux3.18+only)\nEnable or disable per-route features. Only available feature at  this  time  is\necn  to  enable explicit congestion notification when initiating connections to\nthe given destination network.  When responding to a  connection  request  from\nthe given network, ecn will also be used even if the net.ipv4.tcpecn sysctl is\nset to 0.\n\n\nquickack BOOL (Linux 3.11+ only)\nEnable or disable quick ack for connections to this destination.\n\n\nfastopennocookie BOOL (Linux 4.15+ only)\nEnable TCP Fastopen without a cookie for connections to this destination.\n\n\ncongctl NAME (Linux 3.20+ only)\n\ncongctl lock NAME (Linux 3.20+ only)\nSets  a specific TCP congestion control algorithm only for a given destination.\nIf not specified, Linux keeps the current global default TCP congestion control\nalgorithm, or the one set from the application. If the  modifier  lock  is  not\nused,  an  application may nevertheless overwrite the suggested congestion con‐\ntrol algorithm for that destination. If the modifier lock is used, then an  ap‐\nplication  is  not  allowed to overwrite the specified congestion control algo‐\nrithm for that destination, thus it will be enforced/guaranteed to use the pro‐\nposed algorithm.\n\n\nadvmss NUMBER (Linux 2.3.15+ only)\nthe MSS ('Maximal Segment Size') to advertise to these destinations when estab‐\nlishing TCP connections. If it is not given, Linux uses a default value  calcu‐\nlated  from  the  first  hop  device MTU.  (If the path to these destination is\nasymmetric, this guess may be wrong.)\n\n\nreordering NUMBER (Linux 2.3.15+ only)\nMaximal reordering on the path to this destination.  If it is not given,  Linux\nuses the value selected with sysctl variable net/ipv4/tcpreordering.\n\n\nnexthop NEXTHOP\nthe nexthop of a multipath route.  NEXTHOP is a complex value with its own syn‐\ntax similar to the top level argument lists:\n\nvia [ FAMILY ] ADDRESS - is the nexthop router.\n\n\ndev NAME - is the output device.\n\n\nweight  NUMBER  - is a weight for this element of a multipath route re‐\nflecting its relative bandwidth or quality.\n\nThe internal buffer used in iproute2 limits the maximum number of nexthops that\nmay be specified in one go. If only ADDRESS is given, the current  buffer  size\nallows for 144 IPv6 nexthops and 253 IPv4 ones. For IPv4, this effectively lim‐\nits  the number of nexthops possible per route. With IPv6, further nexthops may\nbe appended to the same route via ip route append command.\n\n\nscope SCOPEVAL\nthe scope of the destinations covered by the route prefix.  SCOPEVAL may be  a\nnumber or a string from the file /etc/iproute2/rtscopes.  If this parameter is\nomitted,  ip  assumes scope global for all gatewayed unicast routes, scope link\nfor direct unicast and broadcast routes and scope host for local routes.\n\n\nprotocol RTPROTO\nthe routing protocol identifier of this route.  RTPROTO may be a  number  or  a\nstring  from  the  file /etc/iproute2/rtprotos.  If the routing protocol ID is\nnot given, ip assumes protocol boot (i.e. it assumes the  route  was  added  by\nsomeone  who  doesn't  understand what they are doing). Several protocol values\nhave a fixed interpretation.  Namely:\n\nredirect - the route was installed due to an ICMP redirect.\n\n\nkernel - the route was installed by the  kernel  during  autoconfigura‐\ntion.\n\n\nboot  - the route was installed during the bootup sequence.  If a rout‐\ning daemon starts, it will purge all of them.\n\n\nstatic - the route was installed by the administrator to  override  dy‐\nnamic routing. Routing daemon will respect them and, probably, even ad‐\nvertise them to its peers.\n\n\nra - the route was installed by Router Discovery protocol.\n\n\nThe rest of the values are not reserved and the administrator is free to assign\n(or not to assign) protocol tags.\n\n\nonlink pretend that the nexthop is directly attached to this link, even if it does not\nmatch any interface prefix.\n\n\npref PREF\nthe IPv6 route preference.  PREF is a string specifying the route preference as\ndefined in RFC4191 for Router Discovery messages. Namely:\n\nlow - the route has a lowest priority\n\n\nmedium - the route has a default priority\n\n\nhigh - the route has a highest priority\n\n\n\nnhid ID\nuse nexthop object with given id as nexthop specification.\n\n\nencap ENCAPTYPE ENCAPHDR\nattach tunnel encapsulation attributes to this route.\n\nENCAPTYPE is a string specifying the supported encapsulation type. Namely:\n\nmpls - encapsulation type MPLS\n\nip - IP encapsulation (Geneve, GRE, VXLAN, ...)\n\nbpf - Execution of BPF program\n\nseg6 - encapsulation type IPv6 Segment Routing\n\nseg6local - local SRv6 segment processing\n\nioam6 - encapsulation type IPv6 IOAM\n\nxfrm - encapsulation type XFRM\n\nENCAPHDR is a set of encapsulation attributes specific to the ENCAPTYPE.\n\nmpls\nMPLSLABEL - mpls label stack with labels separated by /\n\n\nttl TTL - TTL to use for MPLS header or 0 to inherit from IP header\n\n\nip\nid  TUNNELID dst REMOTEIP [ src SRC ] [ tos TOS ] [ ttl TTL ] [ key\n] [ csum ] [ seq ]\n\n\nbpf\nin PROG - BPF program to execute for incoming packets\n\n\nout PROG - BPF program to execute for outgoing packets\n\n\nxmit PROG - BPF program to execute for transmitted packets\n\n\nheadroom SIZE - Size of header BPF program will attach (xmit)\n\n\nseg6\nmode inline - Directly  insert  Segment  Routing  Header  after  IPv6\nheader\n\n\nmode encap - Encapsulate packet in an outer IPv6 header with SRH\n\n\nmode  encap.red - Encapsulate packet in an outer IPv6 header with SRH\napplying the reduced segment list. When there is only one segment and\nthe HMAC is not present, the SRH is omitted.\n\n\nmode l2encap - Encapsulate ingress L2  frame  within  an  outer  IPv6\nheader and SRH\n\n\nmode  l2encap.red - Encapsulate ingress L2 frame within an outer IPv6\nheader and SRH applying the reduced segment list. When there is  only\none segment and the HMAC is not present, the SRH is omitted.\n\n\nSEGMENTS - List of comma-separated IPv6 addresses\n\n\nKEYID - Numerical value in decimal representation. See ip-sr(8).\n\n\nseg6local\nSEG6ACTION [ SEG6ACTIONPARAM ] [ count ] - Operation to perform on\nmatching  packets.  The  optional  count attribute is used to collect\nstatistics on the processing of actions.  Three counters  are  imple‐\nmented: 1) packets correctly processed; 2) bytes correctly processed;\n3)  packets  that  cause  a processing error (i.e., missing SID List,\nwrong SID List, etc). To retrieve the counters related to  an  action\nuse  the -s flag in the show command.  The following actions are cur‐\nrently supported (Linux 4.14+ only).\n\nEnd [ flavors FLAVORS ] - Regular SRv6 processing  as  intermediate\nsegment endpoint.  This action only accepts packets with a non-zero\nSegments  Left value. Other matching packets are dropped. The pres‐\nence of flavors can change the regular processing of an End  behav‐\nior  according  to the user-provided Flavor operations and informa‐\ntion carried in the packet.  See Flavors parameters section.\n\nEnd.X nh6 NEXTHOP - Regular SRv6 processing as intermediate segment\nendpoint.  Additionally, forward processed packets to  given  next-\nhop.   This  action  only  accepts packets with a non-zero Segments\nLeft value. Other matching packets are dropped.\n\nEnd.DX6 nh6 NEXTHOP - Decapsulate inner IPv6 packet and forward  it\nto  the  specified next-hop. If the argument is set to ::, then the\nnext-hop is selected according to the local selection  rules.  This\naction  only accepts packets with either a zero Segments Left value\nor no SRH at all, and an inner IPv6 packet. Other matching  packets\nare dropped.\n\nEnd.DT6  {  table | vrftable } TABLEID - Decapsulate the inner IPv6\npacket and forward it according  to  the  specified  lookup  table.\nTABLEID   is   either   a   number   or  a  string  from  the  file\n/etc/iproute2/rttables.  If vrftable is used, the argument must be\na VRF device associated with the table id. Moreover, the VRF  table\nassociated with the table id must be configured with the VRF strict\nmode  turned  on  (net.vrf.strictmode=1). This action only accepts\npackets with either a zero Segments Left value or no  SRH  at  all,\nand an inner IPv6 packet. Other matching packets are dropped.\n\nEnd.DT4  vrftable  TABLEID  - Decapsulate the inner IPv4 packet and\nforward it according to the specified lookup table.  TABLEID is ei‐\nther a number or a string from  the  file  /etc/iproute2/rttables.\nThe  argument  must  be  a VRF device associated with the table id.\nMoreover, the VRF table associated with the table id must  be  con‐\nfigured with the VRF strict mode turned on (net.vrf.strictmode=1).\nThis  action  only accepts packets with either a zero Segments Left\nvalue or no SRH at all, and an inner IPv4  packet.  Other  matching\npackets are dropped.\n\nEnd.DT46  vrftable  TABLEID  -  Decapsulate  the inner IPv4 or IPv6\npacket and forward it according  to  the  specified  lookup  table.\nTABLEID   is   either   a   number   or  a  string  from  the  file\n/etc/iproute2/rttables.  The argument must be a VRF device associ‐\nated with the table id.  Moreover, the VRF  table  associated  with\nthe  table id must be configured with the VRF strict mode turned on\n(net.vrf.strictmode=1). This action only accepts packets with  ei‐\nther a zero Segments Left value or no SRH at all, and an inner IPv4\nor IPv6 packet. Other matching packets are dropped.\n\nEnd.B6  srh segs SEGMENTS [ hmac KEYID ] - Insert the specified SRH\nimmediately after the IPv6 header, update the  DA  with  the  first\nsegment  of  the  newly  inserted  SRH,  then forward the resulting\npacket. The original SRH is not modified. This action only  accepts\npackets with a non-zero Segments Left value. Other matching packets\nare dropped.\n\nEnd.B6.Encaps  srh segs SEGMENTS [ hmac KEYID ] - Regular SRv6 pro‐\ncessing as intermediate segment endpoint.   Additionally,  encapsu‐\nlate  the  matching  packet within an outer IPv6 header followed by\nthe specified SRH. The destination address of the outer IPv6 header\nis set to the first segment of the new SRH. The source  address  is\nset as described in ip-sr(8).\n\nFlavors parameters\n\nThe  flavors represent additional operations that can modify or ex‐\ntend a subset of the existing behaviors.\n\nflavors OPERATION[,OPERATION] [ATTRIBUTES]\n\nOPERATION := { psp | usp | usd | next-csid }\n\nATTRIBUTES := { KEY VALUE } [ ATTRIBUTES ]\n\nKEY := { lblen | nflen }\n\npsp - Penultimate Segment Pop of the SRH (not  yet  supported  in\nkernel)\n\nusp  - Ultimate Segment Pop of the SRH (not yet supported in ker‐\nnel)\n\nusd - Ultimate Segment Decapsulation (not yet supported  in  ker‐\nnel)\n\nnext-csid  -  The  NEXT-C-SID mechanism offers the possibility of\nencoding several SRv6 segments within a single 128  bit  SID  ad‐\ndress.  The  NEXT-C-SID flavor can be configured to support user-\nprovided Locator-Block and Locator-Node Function lengths. If  Lo‐\ncator-Block and/or Locator-Node Function lengths are not provided\nby the user during configuration of an SRv6 End behavior instance\nwith  NEXT-C-SID flavor, the default value is 32-bit for Locator-\nBlock and 16-bit for Locator-Node Function.\n\nlblen VALUE - defines the  Locator-Block  length  for  NEXT-C-SID\nflavor.   The  Locator-Block  length  must  be greater than 0 and\nevenly divisible by 8. This attribute can be used only with NEXT-\nC-SID flavor.\n\nnflen VALUE - defines the Locator-Node Function length for  NEXT-\nC-SID  flavors.  The Locator-Node Function length must be greater\nthan 0 and evenly divisible by 8. This attribute can be used only\nwith NEXT-C-SID flavor.\n\nioam6\nfreq K/N - Inject IOAM in K packets every  N  packets  (default  is\n1/1).\n\nmode  inline  -  Directly  insert  IOAM  after IPv6 header (default\nmode).\n\n\nmode encap - Encapsulate packet in an outer IPv6 header with IOAM.\n\n\nmode auto - Automatically use inline mode for local packets and en‐\ncap mode for in-transit packets.\n\n\ntundst ADDRESS - IPv6 address  of  the  tunnel  destination  (outer\nheader), not used with inline mode.\n\ntype  IOAM6TRACETYPE  -  List of IOAM data required in the trace,\nrepresented by a bitfield (24 bits).\n\n\nns IOAM6NAMESPACE - Numerical value to  represent  an  IOAM  name‐\nspace. See ip-ioam(8).\n\n\nsize IOAM6TRACESIZE - Size, in octets, of the pre-allocated trace\ndata block.\n\nxfrm\nifid IFID  [ linkdev LINKDEV ]\n\n\n\nexpires TIME (Linux 4.4+ only)\nthe  route  will  be  deleted  after  the  expires  time.  Only support IPv6 at\npresent.\n\n\nttl-propagate { enabled | disabled }\nControl whether TTL should be propagated from any encap  into  the  un-encapsu‐\nlated  packet,  overriding any global configuration. Only supported for MPLS at\npresent.\n\n\nip route delete\ndelete route\nip route del has the same arguments as ip route add, but their  semantics  are  a  bit\ndifferent.\n\nKey values (to, tos, preference and table) select the route to delete. If optional at‐\ntributes  are present, ip verifies that they coincide with the attributes of the route\nto delete.  If no route with the given key and attributes  was  found,  ip  route  del\nfails.\n\n\nip route show\nlist routes\nthe  command  displays  the contents of the routing tables or the route(s) selected by\nsome criteria.\n\n\nto SELECTOR (default)\nonly select routes from the given range of destinations.  SELECTOR consists  of\nan  optional modifier (root, match or exact) and a prefix.  root PREFIX selects\nroutes with prefixes not shorter than PREFIX.  F.e.  root 0/0 selects  the  en‐\ntire  routing table.  match PREFIX selects routes with prefixes not longer than\nPREFIX.  F.e.  match 10.0/16 selects 10.0/16, 10/8 and 0/0, but it does not se‐\nlect 10.1/16 and 10.0.0/24.  And exact PREFIX (or just PREFIX)  selects  routes\nwith  this  exact  prefix.  If neither of these options are present, ip assumes\nroot 0/0 i.e. it lists the entire table.\n\n\ntos TOS\n\ndsfield TOS\nonly select routes with the given TOS.\n\n\ntable TABLEID\nshow the routes from this table(s). The default setting is to show table  main.\nTABLEID may either be the ID of a real table or one of the special values:\n\nall - list all of the tables.\n\ncache - dump the routing cache.\n\n\nvrf NAME\nshow the routes for the table associated with the vrf name\n\n\ncloned\n\ncached list  cloned routes i.e. routes which were dynamically forked from other routes\nbecause some route attribute (f.e. MTU) was updated.  Actually, it  is  equiva‐\nlent to table cache.\n\n\nfrom SELECTOR\nthe  same  syntax  as for to, but it binds the source address range rather than\ndestinations.  Note that the from option only works with cloned routes.\n\n\nprotocol RTPROTO\nonly list routes of this protocol.\n\n\nscope SCOPEVAL\nonly list routes with this scope.\n\n\ntype TYPE\nonly list routes of this type.\n\n\ndev NAME\nonly list routes going via this device.\n\n\nvia [ FAMILY ] PREFIX\nonly list routes going via the nexthop routers selected by PREFIX.\n\n\nsrc PREFIX\nonly list routes with preferred source addresses selected by PREFIX.\n\n\nrealm REALMID\n\nrealms FROMREALM/TOREALM\nonly list routes with these realms.\n\n\nip route flush\nflush routing tables\nthis command flushes routes selected by some criteria.\n\n\nThe arguments have the same syntax and semantics as the arguments of  ip  route  show,\nbut  routing  tables are not listed but purged. The only difference is the default ac‐\ntion: show dumps all the IP main routing table but flush prints the helper page.\n\n\nWith the -statistics option, the command becomes verbose. It prints out the number  of\ndeleted routes and the number of rounds made to flush the routing table. If the option\nis  given  twice,  ip  route flush also dumps all the deleted routes in the format de‐\nscribed in the previous subsection.\n\n\nip route get\nget a single route\nthis command gets a single route to a destination and prints its contents  exactly  as\nthe kernel sees it.\n\n\nfibmatch\nReturn full fib lookup matched route. Default is to return the resolved dst en‐\ntry\n\n\nto ADDRESS (default)\nthe destination address.\n\n\nfrom ADDRESS\nthe source address.\n\n\ntos TOS\n\ndsfield TOS\nthe Type Of Service.\n\n\niif NAME\nthe device from which this packet is expected to arrive.\n\n\noif NAME\nforce the output device on which this packet will be routed.\n\n\nmark MARK\nthe firewall mark (fwmark)\n\n\nvrf NAME\nforce the vrf device on which this packet will be routed.\n\n\nipproto PROTOCOL\nip protocol as seen by the route lookup\n\n\nsport NUMBER\nsource port as seen by the route lookup\n\n\ndport NUMBER\ndestination port as seen by the route lookup\n\n\nconnected\nif  no  source  address  (option  from)  was given, relookup the route with the\nsource set to the preferred address received from the first lookup.  If  policy\nrouting is used, it may be a different route.\n\n\nNote  that  this  operation  is  not equivalent to ip route show.  show shows existing\nroutes.  get resolves them and creates new clones if necessary.  Essentially,  get  is\nequivalent to sending a packet along this path.  If the iif argument is not given, the\nkernel  creates  a route to output packets towards the requested destination.  This is\nequivalent to pinging the destination with a subsequent ip route ls cache, however, no\npackets are actually sent. With the iif argument, the kernel pretends  that  a  packet\narrived from this interface and searches for a path to forward the packet.\n\n\nip route save\nsave routing table information to stdout\nThis  command  behaves  like ip route show except that the output is raw data suitable\nfor passing to ip route restore.\n\n\nip route restore\nrestore routing table information from stdin\nThis command expects to read a data stream as returned from ip route  save.   It  will\nattempt  to restore the routing table information exactly as it was at the time of the\nsave, so any translation of information in the stream (such as device indexes) must be\ndone first. Any existing routes are left unchanged. Any routes specified in  the  data\nstream that already exist in the table will be ignored.\n\n"
                }
            ]
        },
        "NOTES": {
            "content": "Starting  with Linux kernel version 3.6, there is no routing cache for IPv4 anymore. Hence ip\nroute show cached will never print any entries on systems with this or newer kernel versions.\n\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "ip ro\nShow all route entries in the kernel.\n\nip route add default via 192.168.1.1 dev eth0\nAdds a default route (for all addresses) via the local gateway 192.168.1.1  that  can  be\nreached on device eth0.\n\nip route add 10.1.1.0/30 encap mpls 200/300 via 10.1.1.1 dev eth0\nAdds an ipv4 route with mpls encapsulation attributes attached to it.\n\nip  -6  route  add 2001:db8:1::/64 encap seg6 mode encap segs 2001:db8:42::1,2001:db8:ffff::2\ndev eth0\nAdds an IPv6 route with SRv6 encapsulation and two segments attached.\n\nip -6 route add 2001:db8:1::/64 encap seg6local action End.DT46 vrftable 100 dev vrf100\nAdds an IPv6 route with SRv6 decapsulation and forward with lookup in VRF table.\n\nip -6 route add 2001:db8:1::/64 encap seg6local action End flavors next-csid dev eth0\nAdds an IPv6 route with SRv6 End behavior with next-csid flavor enabled.\n\nip -6 route add 2001:db8:1::/64 encap seg6local action End flavors next-csid lblen  48  nflen\n16 dev eth0\nAdds an IPv6 route with SRv6 End behavior with next-csid flavor enabled and user-provided\nLocator-Block and Locator-Node Function lengths.\n\nip  -6  route add 2001:db8:1::/64 encap ioam6 freq 2/5 mode encap tundst 2001:db8:42::1 trace\nprealloc type 0x800000 ns 1 size 12 dev eth0\nAdds an IPv6 route with an IOAM Pre-allocated Trace encapsulation (ip6ip6) that only  in‐\ncludes the hop limit and the node id, configured for the IOAM namespace 1 and a pre-allo‐\ncated data block of 12 octets (will be injected in 2 packets every 5 packets).\n\nip route add 10.1.1.0/30 nhid 10\nAdds an ipv4 route using nexthop object with id 10.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "ip(8)\n\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Original Manpage by Michail Litvak <mci@owl.openwall.com>\n\niproute2                                     13 Dec 2012                                 IP-ROUTE(8)",
            "subsections": []
        }
    },
    "summary": "ip-route - routing table management",
    "flags": [],
    "examples": [
        "ip ro",
        "Show all route entries in the kernel.",
        "ip route add default via 192.168.1.1 dev eth0",
        "Adds a default route (for all addresses) via the local gateway 192.168.1.1  that  can  be",
        "reached on device eth0.",
        "ip route add 10.1.1.0/30 encap mpls 200/300 via 10.1.1.1 dev eth0",
        "Adds an ipv4 route with mpls encapsulation attributes attached to it.",
        "ip  -6  route  add 2001:db8:1::/64 encap seg6 mode encap segs 2001:db8:42::1,2001:db8:ffff::2",
        "dev eth0",
        "Adds an IPv6 route with SRv6 encapsulation and two segments attached.",
        "ip -6 route add 2001:db8:1::/64 encap seg6local action End.DT46 vrftable 100 dev vrf100",
        "Adds an IPv6 route with SRv6 decapsulation and forward with lookup in VRF table.",
        "ip -6 route add 2001:db8:1::/64 encap seg6local action End flavors next-csid dev eth0",
        "Adds an IPv6 route with SRv6 End behavior with next-csid flavor enabled.",
        "ip -6 route add 2001:db8:1::/64 encap seg6local action End flavors next-csid lblen  48  nflen",
        "16 dev eth0",
        "Adds an IPv6 route with SRv6 End behavior with next-csid flavor enabled and user-provided",
        "Locator-Block and Locator-Node Function lengths.",
        "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",
        "Adds an IPv6 route with an IOAM Pre-allocated Trace encapsulation (ip6ip6) that only  in‐",
        "cludes the hop limit and the node id, configured for the IOAM namespace 1 and a pre-allo‐",
        "cated data block of 12 octets (will be injected in 2 packets every 5 packets).",
        "ip route add 10.1.1.0/30 nhid 10",
        "Adds an ipv4 route using nexthop object with id 10."
    ],
    "see_also": [
        {
            "name": "ip",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/ip/8/json"
        }
    ]
}