Penguin
Annotated edit history of ip(8) version 2, including all changes. View license author blame.
Rev Author # Line
1 perry 1 IPROUTE
2 !!!IPROUTE
3 NAME
4 DESCRIPTION
5 SEE ALSO
6 AUTHOR
7 THANKS
8 ----
9 !!NAME
10
11
2 AdrianKitto 12 ip - show / manipulate routing, devices, policy routing and tunnels
13 !!SYNOPSIS
14 <verbatim>
15 ip [ OPTIONS ] OBJECT { COMMAND | help }
1 perry 16
17
2 AdrianKitto 18 OBJECT := { link | addr | route | rule | neigh | tunnel | maddr |
19 mroute | monitor }
1 perry 20
21
2 AdrianKitto 22 OPTIONS := { -V[ersion] | -s[tatistics] | -r[esolve] | -f[amily] { inet
23 | inet6 | ipx | dnet | link } | -o[neline] }
1 perry 24
2 AdrianKitto 25 ip link set DEVICE { up | down | arp { on | off } |
26 promisc { on | off } |
27 allmulti { on | off } |
28 dynamic { on | off } |
29 multicast { on | off } |
30 txqueuelen PACKETS |
31 name NEWNAME |
32 address LLADDR | broadcast LLADDR |
33 mtu MTU }
1 perry 34
2 AdrianKitto 35 ip link show [ DEVICE ]
1 perry 36
2 AdrianKitto 37 ip addr { add | del } IFADDR dev STRING
1 perry 38
2 AdrianKitto 39 ip addr { show | flush } [ dev STRING ] [ scope SCOPE-ID ] [ to PREFIX
40 ] [ FLAG-LIST ] [ label PATTERN ]
1 perry 41
2 AdrianKitto 42 IFADDR := PREFIX | ADDR peer PREFIX [ broadcast ADDR ] [ anycast ADDR ]
43 [ label STRING ] [ scope SCOPE-ID ]
1 perry 44
2 AdrianKitto 45 SCOPE-ID := [ host | link | global | NUMBER ]
1 perry 46
2 AdrianKitto 47 FLAG-LIST := [ FLAG-LIST ] FLAG
1 perry 48
2 AdrianKitto 49 FLAG := [ permanent | dynamic | secondary | primary | tentative | dep-
50 recated ]
1 perry 51
2 AdrianKitto 52 ip route { list | flush } SELECTOR
1 perry 53
2 AdrianKitto 54 ip route get ADDRESS [ from ADDRESS iif STRING ] [ oif STRING ] [ tos
55 TOS ]
56
57 ip route { add | del | change | append | replace | monitor } ROUTE
58
59 SELECTOR := [ root PREFIX ] [ match PREFIX ] [ exact PREFIX ] [ table
60 TABLE_ID ] [ proto RTPROTO ] [ type TYPE ] [ scope SCOPE ]
61
62 ROUTE := NODE_SPEC [ INFO_SPEC ]
63
64 NODE_SPEC := [ TYPE ] PREFIX [ tos TOS ] [ table TABLE_ID ] [ proto
65 RTPROTO ] [ scope SCOPE ] [ metric METRIC ]
66
67 INFO_SPEC := NH OPTIONS FLAGS [ nexthop NH ] ...
68
69 NH := [ via ADDRESS ] [ dev STRING ] [ weight NUMBER ] NHFLAGS
70
71 OPTIONS := FLAGS [ mtu NUMBER ] [ advmss NUMBER ] [ rtt NUMBER ] [
72 rttvar NUMBER ] [ window NUMBER ] [ cwnd NUMBER ] [ ssthresh
73 REALM ] [ realms REALM ]
74
75 TYPE := [ unicast | local | broadcast | multicast | throw | unreachable
76 | prohibit | blackhole | nat ]
77
78 TABLE_ID := [ local| main | default | all | NUMBER ]
79
80 SCOPE := [ host | link | global | NUMBER ]
81
82 FLAGS := [ equalize ]
83
84 NHFLAGS := [ onlink | pervasive ]
85
86 RTPROTO := [ kernel | boot | static | NUMBER ]
87
88 ip rule [ list | add | del ] SELECTOR ACTION
89
90 SELECTOR := [ from PREFIX ] [ to PREFIX ] [ tos TOS ] [ fwmark FWMARK ]
91 [ dev STRING ] [ pref NUMBER ]
92
93 ACTION := [ table TABLE_ID ] [ nat ADDRESS ] [ prohibit | reject |
94 unreachable ] [ realms [SRCREALM/]DSTREALM ]
95
96 TABLE_ID := [ local | main | default | NUMBER ]
97
98 ip neigh { add | del | change | replace } { ADDR [ lladdr LLADDR ] [
99 nud { permanent | noarp | stale | reachable } ] | proxy ADDR }
100 [ dev DEV ]
101
102 ip neigh { show | flush } [ to PREFIX ] [ dev DEV ] [ nud STATE ]
103
104 ip tunnel { add | change | del | show } [ NAME ]
105 [ mode { ipip | gre | sit } ]
106 [ remote ADDR ] [ local ADDR ]
107 [ [i|o]seq ] [ [i|o]key KEY ] [ [i|o]csum ] ]
108 [ ttl TTL ] [ tos TOS ] [ [no]pmtudisc ]
109 [ dev PHYS_DEV ]
110
111 ADDR := { IP_ADDRESS | any }
112
113 TOS := { NUMBER | inherit }
114
115 TTL := { 1..255 | inherit }
116
117 KEY := { DOTTED_QUAD | NUMBER }
118
119 ip maddr [ add | del ] MULTIADDR dev STRING
120
121 ip maddr show [ dev STRING ]
122
123 ip mroute show [ PREFIX ] [ from PREFIX ] [ iif DEVICE ]
124
125 ip monitor [ all | LISTofOBJECTS ]
126 </verbatim>
127 !!OPTIONS
128
129 -V, -Version
130 print the version of the ip utility and exit.
131
132
133 -s, -stats, -statistics
134 output more information. If the option appears twice or more,
135 the amount of information increases. As a rule, the information
136 is statistics or some time values.
137
138
139 -f, -family
140 followed by protocol family identifier: inet, inet6 or link
141 ,enforce the protocol family to use. If the option is not
142 present, the protocol family is guessed from other arguments.
143 If the rest of the command line does not give enough information
144 to guess the family, ip falls back to the default one, usually
145 inet or any. link is a special family identifier meaning that
146 no networking protocol is involved.
147
148
149 -4 shortcut for -family inet.
150
151
152 -6 shortcut for -family inet6.
153
154
155 -0 shortcut for -family link.
156
157
158 -o, -oneline
159 output each record on a single line, replacing line feeds with
160 the '\' character. This is convenient when you want to count
161 records with wc(1)
162 or to grep(1) the output.
163
164
165 -r, -resolve
166 use the system's name resolver to print DNS names instead of
167 host addresses.
168
169 !!IP - COMMAND SYNTAX
170 OBJECT
171 link - network device.
172
173
174 address
175 - protocol (IP or IPv6) address on a device.
176
177 neighbour
178 - ARP or NDISC cache entry.
179
180
181 route - routing table entry.
182
183
184 rule - rule in routing policy database.
185
186
187 maddress
188 - multicast address.
189
190
191 mroute - multicast routing cache entry.
192
193
194 tunnel - tunnel over IP.
195
196
197 The names of all objects may be written in full or abbreviated form,
198 f.e. address is abbreviated as addr or just a.
199
200
201 COMMAND
202 Specifies the action to perform on the object. The set of possible
203 actions depends on the object type. As a rule, it is possible to add,
204 delete and show (or list ) objects, but some objects do not allow all
205 of these operations or have some additional commands. The help command
206 is available for all objects. It prints out a list of available com-
207 mands and argument syntax conventions.
208
209 If no command is given, some default command is assumed. Usually it is
210 list or, if the objects of this class cannot be listed, help.
211
212
213 ip link - network device configuration
214 link is a network device and the corresponding commands display and
215 change the state of devices.
216
217
218 ip link set - change device attributes
219 dev NAME (default)
220 NAME specifies network device to operate on.
221
222
223 up and down
224 change the state of the device to UP or DOWN.
225
226 arp on or arp off
227 change the NOARP flag on the device.
228
229
230 multicast on or multicast off
231 change the MULTICAST flag on the device.
232
233
234 dynamic on or dynamic off
235 change the DYNAMIC flag on the device.
236
237
238 name NAME
239 change the name of the device. This operation is not recom-
240 mended if the device is running or has some addresses already
241 configured.
242
243
244 txqueuelen NUMBER
245
246 txqlen NUMBER
247 change the transmit queue length of the device.
248
249
250 mtu NUMBER
251 change the MTU of the device.
252
253
254 address LLADDRESS
255 change the station address of the interface.
256
257
258 broadcast LLADDRESS
259
260 brd LLADDRESS
261
262 peer LLADDRESS
263 change the link layer broadcast address or the peer address when
264 the interface is POINTOPOINT.
265
266
267 Warning: If multiple parameter changes are requested, ip aborts immedi-
268 ately after any of the changes have failed. This is the only case when
269 ip can move the system to an unpredictable state. The solution is to
270 avoid changing several parameters with one ip link set call.
271
272
273 ip link show - display device attributes
274 dev NAME (default)
275 NAME specifies the network device to show. If this argument is
276 omitted all devices are listed.
277
278 up only display running interfaces.
279
280
281 ip address - protocol address management.
282 The address is a protocol (IP or IPv6) address attached to a network
283 device. Each device must have at least one address to use the corre-
284 sponding protocol. It is possible to have several different addresses
285 attached to one device. These addresses are not discriminated, so that
286 the term alias is not quite appropriate for them and we do not use it
287 in this document.
288
289 The ip addr command displays addresses and their properties, adds new
290 addresses and deletes old ones.
291
292
293 ip address add - add new protocol address.
294 dev NAME
295 the name of the device to add the address to.
296
297
298 local ADDRESS (default)
299 the address of the interface. The format of the address depends
300 on the protocol. It is a dotted quad for IP and a sequence of
301 hexadecimal halfwords separated by colons for IPv6. The ADDRESS
302 may be followed by a slash and a decimal number which encodes
303 the network prefix length.
304
305
306 peer ADDRESS
307 the address of the remote endpoint for pointopoint interfaces.
308 Again, the ADDRESS may be followed by a slash and a decimal num-
309 ber, encoding the network prefix length. If a peer address is
310 specified, the local address cannot have a prefix length. The
311 network prefix is associated with the peer rather than with the
312 local address.
313
314
315 broadcast ADDRESS
316 the broadcast address on the interface.
317
318 It is possible to use the special symbols '+' and '-' instead of
319 the broadcast address. In this case, the broadcast address is
320 derived by setting/resetting the host bits of the interface pre-
321 fix.
322
323
324 label NAME
325 Each address may be tagged with a label string. In order to
326 preserve compatibility with Linux-2.0 net aliases, this string
327 must coincide with the name of the device or must be prefixed
328 with the device name followed by colon.
329
330
331 scope SCOPE_VALUE
332 the scope of the area where this address is valid. The avail-
333 able scopes are listed in file /etc/iproute2/rt_scopes.
334 to PREFIX
335 only list addresses matching this prefix.
336
337
338 label PATTERN
339 only list addresses with labels matching the PATTERN. PATTERN
340 is a usual shell style pattern.
341
342
343 dynamic and permanent
344 (IPv6 only) only list addresses installed due to stateless
345 address configuration or only list permanent (not dynamic)
346 addresses.
347
348
349 tentative
350 (IPv6 only) only list addresses which did not pass duplicate
351 address detection.
352
353
354 deprecated
355 (IPv6 only) only list deprecated addresses.
356
357
358 primary and secondary
359 only list primary (or secondary) addresses.
360
361
362 ip address flush - flush protocol addresses
363 This command flushes the protocol addresses selected by some criteria.
364
365
366 This command has the same arguments as show. The difference is that it
367 does not run when no arguments are given.
368
369
370 Warning: This command (and other flush commands described below) is
371 pretty dangerous. If you make a mistake, it will not forgive it, but
372 will cruelly purge all the addresses.
373
374
375 With the -statistics option, the command becomes verbose. It prints out
376 the number of deleted addresses and the number of rounds made to flush
377 the address list. If this option is given twice, ip addr flush also
378 dumps all the deleted addresses in the format described in the previous
379 subsection.
380
381
382 ip neighbour - neighbour/arp tables management.
383 neighbour objects establish bindings between protocol addresses and
384 link layer addresses for hosts sharing the same link. Neighbour
385 entries are organized into tables. The IPv4 neighbour table is known by
386 another name - the ARP table.
387
388
389 The corresponding commands display neighbour bindings and their proper-
390 ties, add new neighbour entries and delete old ones.
391
392
393 ip neighbour add - add a new neighbour entry
394 ip neighbour change - change an existing entry
395 ip neighbour replace - add a new entry or change an existing one
396 These commands create new neighbour records or update existing ones.
397
398
399 to ADDRESS (default)
400 the protocol address of the neighbour. It is either an IPv4 or
401 IPv6 address.
402
403
404 dev NAME
405 the interface to which this neighbour is attached.
406
407
408 lladdr LLADDRESS
409 the link layer address of the neighbour. LLADDRESS can also be
410 null.
411
412
413 nud NUD_STATE
414 the state of the neighbour entry. nud is an abbreviation for
415 'Neigh bour Unreachability Detection'. The state can take one
416 of the following values:
417
418 permanent - the neighbour entry is valid forever and can
419 be only be removed administratively.
420
421
422 noarp - the neighbour entry is valid. No attempts to
423 validate this entry will be made but it can be removed
424 when its lifetime expires.
425
426
427 reachable - the neighbour entry is valid until the
428 reachability timeout expires.
429
430
431 stale - the neighbour entry is valid but suspicious.
432 This option to ip neigh does not change the neighbour
433 state if it was valid and the address is not changed by
434 this command.
435
436
437 ip neighbour delete - delete a neighbour entry
438 This command invalidates a neighbour entry.
439
440
441 The arguments are the same as with ip neigh add, except that lladdr and
442 nud are ignored.
443
444
445 Warning: Attempts to delete or manually change a noarp entry created by
446 the kernel may result in unpredictable behaviour. Particularly, the
447 kernel may try to resolve this address even on a NOARP interface or if
448 the address is multicast or broadcast.
449
450
451 ip neighbour show - list neighbour entries
452 This commands displays neighbour tables.
453
454
455 to ADDRESS (default)
456 the prefix selecting the neighbours to list.
457
458
459 dev NAME
460 only list the neighbours attached to this device.
461
462
463 unused only list neighbours which are not currently in use.
464
465
466 nud NUD_STATE
467 only list neighbour entries in this state. NUD_STATE takes val-
468 ues listed below or the special value all which means all
469 states. This option may occur more than once. If this option
470 is absent, ip lists all entries except for none and noarp.
471
472
473 ip neighbour flush - flush neighbour entries
474 This command flushes neighbour tables, selecting entries to flush by
475 some criteria.
476
477
478 This command has the same arguments as show. The differences are that
479 it does not run when no arguments are given, and that the default
480 neighbour states to be flushed do not include permanent and noarp.
481
482
483 With the -statistics option, the command becomes verbose. It prints
484 out the number of deleted neighbours and the number of rounds made to
485 flush the neighbour table. If the option is given twice, ip neigh
486 flush also dumps all the deleted neighbours.
487
488
489 ip route - routing table management
490 Manipulate route entries in the kernel routing tables keep information
491 about paths to other networked nodes.
492
493 Route types:
494 unicast - the route entry describes real paths to the destina-
495 tions covered by the route prefix.
496
497
498 unreachable - these destinations are unreachable. Packets are
499 discarded and the ICMP message host unreachable is generated.
500 The local senders get an EHOSTUNREACH error.
501
502
503 blackhole - these destinations are unreachable. Packets are
504 discarded silently. The local senders get an EINVAL error.
505
506
507 prohibit - these destinations are unreachable. Packets are
508 discarded and the ICMP message communication administratively
509 prohibited is generated. The local senders get an EACCES
510 error.
511
512
513 local - the destinations are assigned to this host. The pack-
514 ets are looped back and delivered locally.
515
516
517 broadcast - the destinations are broadcast addresses. The
518 packets are sent as link broadcasts.
519
520
521 throw - a special control route used together with policy
522 rules. If such a route is selected, lookup in this table is
523 terminated pretending that no route was found. Without policy
524 routing it is equivalent to the absence of the route in the
525 routing table. The packets are dropped and the ICMP message
526 net unreachable is generated. The local senders get an ENETUN-
527 REACH error.
528
529
530 nat - a special NAT route. Destinations covered by the prefix
531 are considered to be dummy (or external) addresses which
532 require translation to real (or internal) ones before forward-
533 ing. The addresses to translate to are selected with the
534 attribute via.
535
536
537 anycast - not implemented the destinations are anycast
538 addresses assigned to this host. They are mainly equivalent to
539 local with one difference: such addresses are invalid when used
540 as the source address of any packet.
541
542
543 multicast - a special type used for multicast routing. It is
544 not present in normal routing tables.
545
546
547 Route tables: Linux-2.x can pack routes into several routing tables
548 identified by a number in the range from 1 to 255 or by name from the
549 file /etc/iproute2/rt_tables main table (ID 254) and the kernel only
550 uses this table when calculating routes.
551
552
553 Actually, one other table always exists, which is invisible but even
554 more important. It is the local table (ID 255). This table consists
555 of routes for local and broadcast addresses. The kernel maintains this
556 table automatically and the administrator usually need not modify it or
557 even look at it.
558
559 The multiple routing tables enter the game when policy routing is used.
560
561
562 ip route add - add new route
563 ip route change - change route
564 ip route replace - change or add new one
565 to TYPE PREFIX (default)
566 the destination prefix of the route. If TYPE is omitted, ip
567 assumes type unicast. Other values of TYPE are listed above.
568 PREFIX is an IP or IPv6 address optionally followed by a slash
569 and the prefix length. If the length of the prefix is missing,
570 ip assumes a full-length host route. There is also a special
571 PREFIX default - which is equivalent to IP 0/0 or to IPv6 ::/0.
572
573
574 tos TOS
575
576 dsfield TOS
577 the Type Of Service (TOS) key. This key has no associated mask
578 and the longest match is understood as: First, compare the TOS
579 of the route and of the packet. If they are not equal, then the
580 packet may still match a route with a zero TOS. TOS is either
581 an 8 bit hexadecimal number or an identifier from
582 /etc/iproute2/rt_dsfield.
583
584
585 metric NUMBER
586
587 preference NUMBER
588 the preference value of the route. NUMBER is an arbitrary 32bit
589 number.
590
591
592 table TABLEID
593 the table to add this route to. TABLEID may be a number or a
594 string from the file /etc/iproute2/rt_tables. If this parameter
595 is omitted, ip assumes the main table, with the exception of
596 local , broadcast and nat routes, which are put into the local
597 table by default.
598
599
600 dev NAME
601 the output device name.
602
603
604 via ADDRESS
605 the address of the nexthop router. Actually, the sense of this
606 field depends on the route type. For normal unicast routes it
607 is either the true next hop router or, if it is a direct route
608 installed in BSD compatibility mode, it can be a local address
609 of the interface. For NAT routes it is the first address of the
610 block of translated IP destinations.
611
612
613 src ADDRESS
614 the source address to prefer when sending to the destinations
615 covered by the route prefix.
616
617
618 realm REALMID
619 the realm to which this route is assigned. REALMID may be a
620 number or a string from the file /etc/iproute2/rt_realms.
621
622
623 mtu MTU
624
625 mtu lock MTU
626 the MTU along the path to the destination. If the modifier lock
627 is not used, the MTU may be updated by the kernel due to Path
628 MTU Discovery. If the modifier lock is used, no path MTU dis-
629 covery will be tried, all packets will be sent without the DF
630 bit in IPv4 case or fragmented to MTU for IPv6.
631
632
633 window NUMBER
634 the maximal window for TCP to advertise to these destinations,
635 measured in bytes. It limits maximal data bursts that our TCP
636 peers are allowed to send to us.
637
638
639 rtt NUMBER
640 the initial RTT ('Round Trip Time') estimate.
641
642
643 rttvar NUMBER (2.3.15+ only)
644 the initial RTT variance estimate.
645
646
647 ssthresh NUMBER (2.3.15+ only)
648 an estimate for the initial slow start threshold.
649
650
651 cwnd NUMBER (2.3.15+ only)
652 the clamp for congestion window. It is ignored if the lock flag
653 is not used.
654
655
656 advmss NUMBER (2.3.15+ only)
657 the MSS ('Maximal Segment Size') to advertise to these destina-
658 tions when establishing TCP connections. If it is not given,
659 Linux uses a default value calculated from the first hop device
660 MTU. (If the path to these destination is asymmetric, this
661 guess may be wrong.)
662
663
664 reordering NUMBER (2.3.15+ only)
665 Maximal reordering on the path to this destination. If it is
666 not given, Linux uses the value selected with sysctl variable
667 net/ipv4/tcp_reordering.
668
669
670 nexthop NEXTHOP
671 the nexthop of a multipath route. NEXTHOP is a complex value
672 with its own syntax similar to the top level argument lists:
673
674 via ADDRESS - is the nexthop router.
675
676
677 dev NAME - is the output device.
678
679
680 weight NUMBER - is a weight for this element of a multi-
681 path route reflecting its relative bandwidth or quality.
682
683
684 scope SCOPE_VAL
685 the scope of the destinations covered by the route prefix.
686 SCOPE_VAL may be a number or a string from the file
687 /etc/iproute2/rt_scopes. If this parameter is omitted, ip
688 assumes scope global for all gatewayed unicast routes, scope
689 link for direct unicast and broadcast routes and scope host for
690 local routes.
691
692
693 protocol RTPROTO
694 the routing protocol identifier of this route. RTPROTO may be a
695 number or a string from the file /etc/iproute2/rt_protos. If
696 the routing protocol ID is not given, ip assumes protocol boot
697 (i.e. it assumes the route was added by someone who doesn't
698 understand what they are doing). Several protocol values have a
699 fixed interpretation. Namely:
700
701 redirect - the route was installed due to an ICMP redi-
702 rect.
703
704
705 kernel - the route was installed by the kernel during
706 autoconfiguration.
707
708
709 boot - the route was installed during the bootup
710 sequence. If a routing daemon starts, it will purge all
711 of them.
712
713
714 static - the route was installed by the administrator to
715 override dynamic routing. Routing daemon will respect
716 them and, probably, even advertise them to its peers.
717
718
719 ra - the route was installed by Router Discovery proto-
720 col.
721
722 The rest of the values are not reserved and the administrator is
723 free to assign (or not to assign) protocol tags.
724
725
726 onlink pretend that the nexthop is directly attached to this link, even
727 if it does not match any interface prefix.
728
729
730 equalize
731 allow packet by packet randomization on multipath routes. With-
732 out this modifier, the route will be frozen to one selected nex-
733 thop, so that load splitting will only occur on per-flow base.
734 equalize only works if the kernel is patched.
735
736
737 ip route delete - delete route
738 ip route del has the same arguments as ip route add, but their seman-
739 tics are a bit different.
740
741 Key values (to, tos, preference and table) select the route to delete.
742 If optional attributes are present, ip verifies that they coincide with
743 the attributes of the route to delete. If no route with the given key
744 and attributes was found, ip route del fails.
745
746
747 ip route show - list routes
748 the command displays the contents of the routing tables or the route(s)
749 selected by some criteria.
750
751
752 to SELECTOR (default)
753 only select routes from the given range of destinations. SELEC-
754 TOR consists of an optional modifier (root, match or exact) and
755 a prefix. root PREFIX selects routes with prefixes not shorter
756 than PREFIX. F.e. root 0/0 selects the entire routing table.
757 match PREFIX selects routes with prefixes not longer than PRE-
758 FIX. F.e. match 10.0/16 selects 10.0/16, 10/8 and 0/0, but it
759 does not select 10.1/16 and 10.0.0/24. And exact PREFIX (or
760 just PREFIX) selects routes with this exact prefix. If neither
761 of these options are present, ip assumes root 0/0 i.e. it lists
762 the entire table.
763
764
765 tos TOS
766 dsfield TOS only select routes with the given TOS.
767
768
769 table TABLEID
770 show the routes from this table(s). The default setting is to
771 show tablemain. TABLEID may either be the ID of a real table or
772 one of the special values:
773 all - list all of the tables.
774
775 cache - dump the routing cache.
776
777
778 cloned
779
780 cached list cloned routes i.e. routes which were dynamically forked
781 from other routes because some route attribute (f.e. MTU) was
782 updated. Actually, it is equivalent to table cache.
783
784
785 from SELECTOR
786 the same syntax as for to, but it binds the source address range
787 rather than destinations. Note that the from option only works
788 with cloned routes.
789
790
791 protocol RTPROTO
792 only list routes of this protocol.
793
794
795 scope SCOPE_VAL
796 only list routes with this scope.
797
798
799 type TYPE
800 only list routes of this type.
801
802
803 dev NAME
804 only list routes going via this device.
805
806
807 via PREFIX
808 only list routes going via the nexthop routers selected by PRE-
809 FIX.
810
811
812 src PREFIX
813 only list routes with preferred source addresses selected by
814 PREFIX.
815
816
817 realm REALMID
818
819 realms FROMREALM/TOREALM
820 only list routes with these realms.
821
822
823 ip route flush - flush routing tables
824 this command flushes routes selected by some criteria.
825
826 The arguments have the same syntax and semantics as the arguments of ip
827 route show, but routing tables are not listed but purged. The only
828 difference is the default action: show dumps all the IP main routing
829 table but flush prints the helper page.
830
831
832 With the -statistics option, the command becomes verbose. It prints out
833 the number of deleted routes and the number of rounds made to flush the
834 routing table. If the option is given twice, ip route flush also dumps
835 all the deleted routes in the format described in the previous subsec-
836 tion.
837
838
839 ip route get - get a single route
840 this command gets a single route to a destination and prints its con-
841 tents exactly as the kernel sees it.
842
843
844 to ADDRESS (default)
845 the destination address.
846
847
848 from ADDRESS
849 the source address.
850
851
852 tos TOS
853
854 dsfield TOS
855 the Type Of Service.
856
857
858 iif NAME
859 the device from which this packet is expected to arrive.
860
861
862 oif NAME
863 force the output device on which this packet will be routed.
864
865
866 connected
867 if no source address (option from) was given, relookup the route
868 with the source set to the preferred address received from the
869 first lookup. If policy routing is used, it may be a different
870 route.
871
872
873 Note that this operation is not equivalent to ip route show. show
874 shows existing routes. get resolves them and creates new clones if
875 necessary. Essentially, get is equivalent to sending a packet along
876 this path. If the iif argument is not given, the kernel creates a
877 route to output packets towards the requested destination. This is
878 equivalent to pinging the destination with a subsequent ip route ls
879 cache, however, no packets are actually sent. With the iif argument,
880 the kernel pretends that a packet arrived from this interface and
881 searches for a path to forward the packet.
882
883
884 ip rule - routing policy database management
885 Rules in the routing policy database control the route selection algo-
886 rithm.
887
888
889 Classic routing algorithms used in the Internet make routing decisions
890 based only on the destination address of packets (and in theory, but
891 not in practice, on the TOS field).
892
893
894 In some circumstances we want to route packets differently depending
895 not only on destination addresses, but also on other packet fields:
896 source address, IP protocol, transport protocol ports or even packet
897 payload. This task is called 'policy routing'.
898
899
900 To solve this task, the conventional destination based routing table,
901 ordered according to the longest match rule, is replaced with a 'rout-
902 ing policy database' (or RPDB), which selects routes by executing some
903 set of rules.
904
905
906 Each policy routing rule consists of a selector and an action predi-
907 cate. The RPDB is scanned in the order of increasing priority. The
908 selector of each rule is applied to {source address, destination
909 address, incoming interface, tos, fwmark} and, if the selector matches
910 the packet, the action is performed. The action predicate may return
911 with success. In this case, it will either give a route or failure
912 indication and the RPDB lookup is terminated. Otherwise, the RPDB pro-
913 gram continues on the next rule.
914
915
916 Semantically, natural action is to select the nexthop and the output
917 device.
918
919
920 At startup time the kernel configures the default RPDB consisting of
921 three rules:
922
923
924 1. Priority: 0, Selector: match anything, Action: lookup routing
925 table local (ID 255). The local table is a special routing ta-
926 ble containing high priority control routes for local and broad-
927 cast addresses.
928
929 Rule 0 is special. It cannot be deleted or overridden.
930
931
932 2. Priority: 32766, Selector: match anything, Action: lookup rout-
933 ing table main (ID 254). The main table is the normal routing
934 table containing all non-policy routes. This rule may be deleted
935 and/or overridden with other ones by the administrator.
936
937
938 3. Priority: 32767, Selector: match anything, Action: lookup rout-
939 ing table default (ID 253). The default table is empty. It is
940 reserved for some post-processing if no previous default rules
941 selected the packet. This rule may also be deleted.
942
943
944 Each RPDB entry has additional attributes. F.e. each rule has a
945 pointer to some routing table. NAT and masquerading rules have an
946 attribute to select new IP address to translate/masquerade. Besides
947 that, rules have some optional attributes, which routes have, namely
948 realms. These values do not override those contained in the routing
949 tables. They are only used if the route did not select any attributes.
950
951
952 The RPDB may contain rules of the following types:
953
954 unicast - the rule prescribes to return the route found in the
955 routing table referenced by the rule.
956
957 blackhole - the rule prescribes to silently drop the packet.
958
959 unreachable - the rule prescribes to generate a 'Network is
960 unreachable' error.
961
962 prohibit - the rule prescribes to generate 'Communication is
963 administratively prohibited' error.
964
965 nat - the rule prescribes to translate the source address of
966 the IP packet into some other value.
967
968
969 ip rule add - insert a new rule
970 ip rule delete - delete a rule
971 type TYPE (default)
972 the type of this rule. The list of valid types was given in the
973 previous subsection.
974
975
976 from PREFIX
977 select the source prefix to match.
978
979
980 to PREFIX
981 select the destination prefix to match.
982
983
984 iif NAME
985 select the incoming device to match. If the interface is loop-
986 back, the rule only matches packets originating from this host.
987 This means that you may create separate routing tables for for-
988 warded and local packets and, hence, completely segregate them.
989
990
991 tos TOS
992
993 dsfield TOS
994 select the TOS value to match.
995
996
997 fwmark MARK
998 select the fwmark value to match.
999
1000
1001 priority PREFERENCE
1002 the priority of this rule. Each rule should have an explicitly
1003 set unique priority value.
1004
1005
1006 table TABLEID
1007 the routing table identifier to lookup if the rule selector
1008 matches.
1009
1010
1011 realms FROM/TO
1012 Realms to select if the rule matched and the routing table
1013 lookup succeeded. Realm TO is only used if the route did not
1014 select any realm.
1015
1016
1017 nat ADDRESS
1018 The base of the IP address block to translate (for source
1019 addresses). The ADDRESS may be either the start of the block of
1020 NAT addresses (selected by NAT routes) or a local host address
1021 (or even zero). In the last case the router does not translate
1022 the packets, but masquerades them to this address.
1023
1024 Warning: Changes to the RPDB made with these commands do not
1025 become active immediately. It is assumed that after a script
1026 finishes a batch of updates, it flushes the routing cache with
1027 ip route flush cache.
1028
1029
1030 ip rule show - list rules
1031 This command has no arguments.
1032
1033
1034 ip maddress - multicast addresses management
1035 maddress objects are multicast addresses.
1036
1037
1038 ip maddress show - list multicast addresses
1039 dev NAME (default)
1040 the device name.
1041
1042
1043 ip maddress add - add a multicast address
1044 ip maddress delete - delete a multicast address
1045 these commands attach/detach a static link layer multicast address to
1046 listen on the interface. Note that it is impossible to join protocol
1047 multicast groups statically. This command only manages link layer
1048 addresses.
1049
1050
1051 address LLADDRESS (default)
1052 the link layer multicast address.
1053
1054
1055 dev NAME
1056 the device to join/leave this multicast address.
1057
1058
1059 ip mroute - multicast routing cache management
1060 mroute objects are multicast routing cache entries created by a user
1061 level mrouting daemon (f.e. pimd or mrouted ).
1062
1063 Due to the limitations of the current interface to the multicast rout-
1064 ing engine, it is impossible to change mroute objects administratively,
1065 so we may only display them. This limitation will be removed in the
1066 future.
1067
1068
1069 ip mroute show - list mroute cache entries
1070 to PREFIX (default)
1071 the prefix selecting the destination multicast addresses to
1072 list.
1073
1074
1075 iif NAME
1076 the interface on which multicast packets are received.
1077
1078
1079 from PREFIX
1080 the prefix selecting the IP source addresses of the multicast
1081 route.
1082
1083
1084 ip tunnel - tunnel configuration
1085 tunnel objects are tunnels, encapsulating packets in IPv4 packets and
1086 then sending them over the IP infrastructure.
1087
1088
1089 ip tunnel add - add a new tunnel
1090 ip tunnel change - change an existing tunnel
1091 ip tunnel delete - destroy a tunnel
1092 name NAME (default)
1093 select the tunnel device name.
1094
1095
1096 mode MODE
1097 set the tunnel mode. Three modes are currently available: ipip,
1098 sit and gre.
1099
1100
1101 remote ADDRESS
1102 set the remote endpoint of the tunnel.
1103
1104
1105 local ADDRESS
1106 set the fixed local address for tunneled packets. It must be an
1107 address on another interface of this host.
1108
1109
1110 ttl N set a fixed TTL N on tunneled packets. N is a number in the
1111 range 1--255. 0 is a special value meaning that packets inherit
1112 the TTL value. The default value is: inherit.
1113
1114
1115 tos T
1116
1117 dsfield T
1118 set a fixed TOS T on tunneled packets. The default value is:
1119 inherit.
1120
1121
1122 dev NAME
1123 bind the tunnel to the device NAME so that tunneled packets will
1124 only be routed via this device and will not be able to escape to
1125 another device when the route to endpoint changes.
1126
1127
1128 nopmtudisc
1129 disable Path MTU Discovery on this tunnel. It is enabled by
1130 default. Note that a fixed ttl is incompatible with this
1131 option: tunnelling with a fixed ttl always makes pmtu discovery.
1132
1133
1134 key K
1135
1136 ikey K
1137
1138 okey K ( only GRE tunnels ) use keyed GRE with key K. K is either a
1139 number or an IP address-like dotted quad. The key parameter
1140 sets the key to use in both directions. The ikey and okey
1141 parameters set different keys for input and output.
1142
1143
1144 csum, icsum, ocsum
1145 ( only GRE tunnels ) generate/require checksums for tunneled
1146 packets. The ocsum flag calculates checksums for outgoing pack-
1147 ets. The icsum flag requires that all input packets have the
1148 correct checksum. The csum flag is equivalent to the combina-
1149 tion icsum ocsum.
1150
1151
1152 seq, iseq, oseq
1153 ( only GRE tunnels ) serialize packets. The oseq flag enables
1154 sequencing of outgoing packets. The iseq flag requires that all
1155 input packets are serialized. The seq flag is equivalent to the
1156 combination iseq oseq. It isn't work. Don't use it.
1157
1158
1159 ip tunnel show - list tunnels
1160 This command has no arguments.
1161
1162
1163 ip monitor and rtmon - state monitoring
1164 The ip utility can monitor the state of devices, addresses and routes
1165 continuously. This option has a slightly different format. Namely,
1166 the monitor command is the first in the command line and then the
1167 object list follows:
1168
1169 ip monitor [ all | LISTofOBJECTS ]
1170
1171 OBJECT-LIST is the list of object types that we want to monitor. It
1172 may contain link, address and route. If no file argument is given, ip
1173 opens RTNETLINK, listens on it and dumps state changes in the format
1174 described in previous sections.
1175
1176
1177 If a file name is given, it does not listen on RTNETLINK, but opens the
1178 file containing RTNETLINK messages saved in binary format and dumps
1179 them. Such a history file can be generated with the rtmon utility.
1180 This utility has a command line syntax similar to ip monitor. Ideally,
1181 rtmon should be started before the first network configuration command
1182 is issued. F.e. if you insert:
1183
1184 rtmon file /var/log/rtmon.log
1185
1186 in a startup script, you will be able to view the full history later.
1187
1188
1189 Certainly, it is possible to start rtmon at any time. It prepends the
1190 history with the state snapshot dumped at the moment of starting.
1191
1192
1193 !!HISTORY
1194 ip was written by Alexey N. Kuznetsov and added in Linux 2.2.
1195
1196 !!SEE ALSO
1197 [tc(8)]
1198 IP Command reference ip-cref.ps
1199 IP tunnels ip-cref.ps
1200 http://lartc.org/
1201
1202
1203 !!AUTHOR
1204 Manpage maintained by Michail Litvak <mci@owl.openwall.com>
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.