]>
Commit | Line | Data |
---|---|---|
e509fb1b | 1 | .TH IP\-ROUTE 8 "13 Dec 2012" "iproute2" "Linux" |
761a1e60 CT |
2 | .SH "NAME" |
3 | ip-route \- routing table management | |
4 | .SH "SYNOPSIS" | |
5 | .sp | |
6 | .ad l | |
7 | .in +8 | |
8 | .ti -8 | |
9 | .B ip | |
e509fb1b | 10 | .RI "[ " ip-OPTIONS " ]" |
761a1e60 CT |
11 | .B route |
12 | .RI " { " COMMAND " | " | |
13 | .BR help " }" | |
14 | .sp | |
15 | .ti -8 | |
16 | ||
17 | .ti -8 | |
18 | .BR "ip route" " { " | |
19 | .BR list " | " flush " } " | |
20 | .I SELECTOR | |
21 | ||
22 | .ti -8 | |
23 | .BR "ip route save" | |
24 | .I SELECTOR | |
25 | ||
26 | .ti -8 | |
27 | .BR "ip route restore" | |
28 | ||
29 | .ti -8 | |
30 | .B ip route get | |
31 | .IR ADDRESS " [ " | |
32 | .BI from " ADDRESS " iif " STRING" | |
33 | .RB " ] [ " oif | |
34 | .IR STRING " ] [ " | |
35 | .B tos | |
36 | .IR TOS " ]" | |
37 | ||
38 | .ti -8 | |
39 | .BR "ip route" " { " add " | " del " | " change " | " append " | "\ | |
40 | replace " } " | |
41 | .I ROUTE | |
42 | ||
43 | .ti -8 | |
44 | .IR SELECTOR " := " | |
45 | .RB "[ " root | |
46 | .IR PREFIX " ] [ " | |
47 | .B match | |
48 | .IR PREFIX " ] [ " | |
49 | .B exact | |
50 | .IR PREFIX " ] [ " | |
51 | .B table | |
52 | .IR TABLE_ID " ] [ " | |
53 | .B proto | |
54 | .IR RTPROTO " ] [ " | |
55 | .B type | |
56 | .IR TYPE " ] [ " | |
57 | .B scope | |
58 | .IR SCOPE " ]" | |
59 | ||
60 | .ti -8 | |
61 | .IR ROUTE " := " NODE_SPEC " [ " INFO_SPEC " ]" | |
62 | ||
63 | .ti -8 | |
64 | .IR NODE_SPEC " := [ " TYPE " ] " PREFIX " [" | |
65 | .B tos | |
66 | .IR TOS " ] [ " | |
67 | .B table | |
68 | .IR TABLE_ID " ] [ " | |
69 | .B proto | |
70 | .IR RTPROTO " ] [ " | |
71 | .B scope | |
72 | .IR SCOPE " ] [ " | |
73 | .B metric | |
74 | .IR METRIC " ]" | |
75 | ||
76 | .ti -8 | |
77 | .IR INFO_SPEC " := " "NH OPTIONS FLAGS" " [" | |
78 | .B nexthop | |
79 | .IR NH " ] ..." | |
80 | ||
81 | .ti -8 | |
82 | .IR NH " := [ " | |
83 | .B via | |
84 | .IR ADDRESS " ] [ " | |
85 | .B dev | |
86 | .IR STRING " ] [ " | |
87 | .B weight | |
88 | .IR NUMBER " ] " NHFLAGS | |
89 | ||
90 | .ti -8 | |
91 | .IR OPTIONS " := " FLAGS " [ " | |
92 | .B mtu | |
93 | .IR NUMBER " ] [ " | |
94 | .B advmss | |
95 | .IR NUMBER " ] [ " | |
96 | .B rtt | |
97 | .IR TIME " ] [ " | |
98 | .B rttvar | |
99 | .IR TIME " ] [ " | |
4b8000f3 RG |
100 | .B reordering |
101 | .IR NUMBER " ] [ " | |
761a1e60 CT |
102 | .B window |
103 | .IR NUMBER " ] [ " | |
104 | .B cwnd | |
105 | .IR NUMBER " ] [ " | |
106 | .B ssthresh | |
107 | .IR REALM " ] [ " | |
108 | .B realms | |
109 | .IR REALM " ] [ " | |
110 | .B rto_min | |
111 | .IR TIME " ] [ " | |
112 | .B initcwnd | |
113 | .IR NUMBER " ] [ " | |
114 | .B initrwnd | |
4b8000f3 | 115 | .IR NUMBER " ] [ " |
29d1f730 FW |
116 | .B features |
117 | .IR FEATURES " ] [ " | |
b37f2c89 | 118 | .B quickack |
6ef87f9c DB |
119 | .IR BOOL " ] [ " |
120 | .B congctl | |
121 | .IR NAME " ]" | |
761a1e60 CT |
122 | |
123 | .ti -8 | |
124 | .IR TYPE " := [ " | |
125 | .BR unicast " | " local " | " broadcast " | " multicast " | "\ | |
126 | throw " | " unreachable " | " prohibit " | " blackhole " | " nat " ]" | |
127 | ||
128 | .ti -8 | |
129 | .IR TABLE_ID " := [ " | |
130 | .BR local "| " main " | " default " | " all " |" | |
131 | .IR NUMBER " ]" | |
132 | ||
133 | .ti -8 | |
134 | .IR SCOPE " := [ " | |
135 | .BR host " | " link " | " global " |" | |
136 | .IR NUMBER " ]" | |
137 | ||
138 | .ti -8 | |
139 | .IR NHFLAGS " := [ " | |
140 | .BR onlink " | " pervasive " ]" | |
141 | ||
142 | .ti -8 | |
143 | .IR RTPROTO " := [ " | |
144 | .BR kernel " | " boot " | " static " |" | |
145 | .IR NUMBER " ]" | |
146 | ||
29d1f730 FW |
147 | .ti -8 |
148 | .IR FEATURES " := [ " | |
149 | .BR ecn " | ]" | |
150 | ||
761a1e60 CT |
151 | |
152 | .SH DESCRIPTION | |
153 | .B ip route | |
154 | is used to manipulate entries in the kernel routing tables. | |
155 | .sp | |
156 | .B Route types: | |
157 | ||
158 | .in +8 | |
159 | .B unicast | |
160 | - the route entry describes real paths to the destinations covered | |
161 | by the route prefix. | |
162 | ||
163 | .sp | |
164 | .B unreachable | |
a89d5329 | 165 | - these destinations are unreachable. Packets are discarded and the |
761a1e60 CT |
166 | ICMP message |
167 | .I host unreachable | |
168 | is generated. | |
169 | The local senders get an | |
170 | .I EHOSTUNREACH | |
171 | error. | |
172 | ||
173 | .sp | |
174 | .B blackhole | |
a89d5329 | 175 | - these destinations are unreachable. Packets are discarded silently. |
761a1e60 CT |
176 | The local senders get an |
177 | .I EINVAL | |
178 | error. | |
179 | ||
180 | .sp | |
181 | .B prohibit | |
a89d5329 | 182 | - these destinations are unreachable. Packets are discarded and the |
761a1e60 CT |
183 | ICMP message |
184 | .I communication administratively prohibited | |
a89d5329 | 185 | is generated. The local senders get an |
761a1e60 CT |
186 | .I EACCES |
187 | error. | |
188 | ||
189 | .sp | |
190 | .B local | |
a89d5329 | 191 | - the destinations are assigned to this host. The packets are looped |
761a1e60 CT |
192 | back and delivered locally. |
193 | ||
194 | .sp | |
195 | .B broadcast | |
a89d5329 | 196 | - the destinations are broadcast addresses. The packets are sent as |
761a1e60 CT |
197 | link broadcasts. |
198 | ||
199 | .sp | |
200 | .B throw | |
201 | - a special control route used together with policy rules. If such a | |
202 | route is selected, lookup in this table is terminated pretending that | |
a89d5329 PŠ |
203 | no route was found. Without policy routing it is equivalent to the |
204 | absence of the route in the routing table. The packets are dropped | |
761a1e60 CT |
205 | and the ICMP message |
206 | .I net unreachable | |
a89d5329 | 207 | is generated. The local senders get an |
761a1e60 CT |
208 | .I ENETUNREACH |
209 | error. | |
210 | ||
211 | .sp | |
212 | .B nat | |
a89d5329 | 213 | - a special NAT route. Destinations covered by the prefix |
761a1e60 | 214 | are considered to be dummy (or external) addresses which require translation |
a89d5329 | 215 | to real (or internal) ones before forwarding. The addresses to translate to |
761a1e60 | 216 | are selected with the attribute |
1b3c149b | 217 | .BR "via" . |
761a1e60 CT |
218 | .B Warning: |
219 | Route NAT is no longer supported in Linux 2.6. | |
220 | ||
761a1e60 CT |
221 | .sp |
222 | .B anycast | |
223 | .RI "- " "not implemented" | |
224 | the destinations are | |
225 | .I anycast | |
a89d5329 | 226 | addresses assigned to this host. They are mainly equivalent |
761a1e60 CT |
227 | to |
228 | .B local | |
229 | with one difference: such addresses are invalid when used | |
230 | as the source address of any packet. | |
231 | ||
232 | .sp | |
233 | .B multicast | |
a89d5329 | 234 | - a special type used for multicast routing. It is not present in |
761a1e60 CT |
235 | normal routing tables. |
236 | .in -8 | |
237 | ||
238 | .P | |
239 | .B Route tables: | |
240 | Linux-2.x can pack routes into several routing tables identified | |
241 | by a number in the range from 1 to 2^31 or by name from the file | |
242 | .B @SYSCONFDIR@/rt_tables | |
243 | By default all normal routes are inserted into the | |
244 | .B main | |
245 | table (ID 254) and the kernel only uses this table when calculating routes. | |
246 | Values (0, 253, 254, and 255) are reserved for built-in use. | |
247 | ||
248 | .sp | |
249 | Actually, one other table always exists, which is invisible but | |
a89d5329 | 250 | even more important. It is the |
761a1e60 | 251 | .B local |
a89d5329 PŠ |
252 | table (ID 255). This table |
253 | consists of routes for local and broadcast addresses. The kernel maintains | |
761a1e60 CT |
254 | this table automatically and the administrator usually need not modify it |
255 | or even look at it. | |
256 | ||
257 | The multiple routing tables enter the game when | |
258 | .I policy routing | |
259 | is used. | |
260 | ||
61f541fe | 261 | .TP |
262 | ip route add | |
263 | add new route | |
264 | .TP | |
265 | ip route change | |
266 | change route | |
267 | .TP | |
268 | ip route replace | |
269 | change or add new one | |
270 | .RS | |
761a1e60 CT |
271 | .TP |
272 | .BI to " TYPE PREFIX " (default) | |
a89d5329 | 273 | the destination prefix of the route. If |
761a1e60 CT |
274 | .I TYPE |
275 | is omitted, | |
276 | .B ip | |
277 | assumes type | |
278 | .BR "unicast" . | |
279 | Other values of | |
280 | .I TYPE | |
281 | are listed above. | |
282 | .I PREFIX | |
283 | is an IP or IPv6 address optionally followed by a slash and the | |
a89d5329 | 284 | prefix length. If the length of the prefix is missing, |
761a1e60 | 285 | .B ip |
a89d5329 | 286 | assumes a full-length host route. There is also a special |
761a1e60 CT |
287 | .I PREFIX |
288 | .B default | |
289 | - which is equivalent to IP | |
290 | .B 0/0 | |
291 | or to IPv6 | |
292 | .BR "::/0" . | |
293 | ||
294 | .TP | |
295 | .BI tos " TOS" | |
296 | .TP | |
297 | .BI dsfield " TOS" | |
a89d5329 | 298 | the Type Of Service (TOS) key. This key has no associated mask and |
761a1e60 | 299 | the longest match is understood as: First, compare the TOS |
a89d5329 | 300 | of the route and of the packet. If they are not equal, then the packet |
761a1e60 CT |
301 | may still match a route with a zero TOS. |
302 | .I TOS | |
303 | is either an 8 bit hexadecimal number or an identifier | |
304 | from | |
305 | .BR "@SYSCONFDIR@/rt_dsfield" . | |
306 | ||
307 | .TP | |
308 | .BI metric " NUMBER" | |
309 | .TP | |
310 | .BI preference " NUMBER" | |
311 | the preference value of the route. | |
312 | .I NUMBER | |
313 | is an arbitrary 32bit number. | |
314 | ||
315 | .TP | |
316 | .BI table " TABLEID" | |
317 | the table to add this route to. | |
318 | .I TABLEID | |
319 | may be a number or a string from the file | |
320 | .BR "@SYSCONFDIR@/rt_tables" . | |
321 | If this parameter is omitted, | |
322 | .B ip | |
323 | assumes the | |
324 | .B main | |
325 | table, with the exception of | |
1b3c149b | 326 | .BR local ", " broadcast " and " nat |
761a1e60 CT |
327 | routes, which are put into the |
328 | .B local | |
329 | table by default. | |
330 | ||
331 | .TP | |
332 | .BI dev " NAME" | |
333 | the output device name. | |
334 | ||
335 | .TP | |
336 | .BI via " ADDRESS" | |
a89d5329 PŠ |
337 | the address of the nexthop router. Actually, the sense of this field |
338 | depends on the route type. For normal | |
761a1e60 CT |
339 | .B unicast |
340 | routes it is either the true next hop router or, if it is a direct | |
341 | route installed in BSD compatibility mode, it can be a local address | |
a89d5329 | 342 | of the interface. For NAT routes it is the first address of the block |
761a1e60 CT |
343 | of translated IP destinations. |
344 | ||
345 | .TP | |
346 | .BI src " ADDRESS" | |
347 | the source address to prefer when sending to the destinations | |
348 | covered by the route prefix. | |
349 | ||
350 | .TP | |
351 | .BI realm " REALMID" | |
352 | the realm to which this route is assigned. | |
353 | .I REALMID | |
354 | may be a number or a string from the file | |
355 | .BR "@SYSCONFDIR@/rt_realms" . | |
356 | ||
357 | .TP | |
358 | .BI mtu " MTU" | |
359 | .TP | |
360 | .BI "mtu lock" " MTU" | |
a89d5329 | 361 | the MTU along the path to the destination. If the modifier |
761a1e60 CT |
362 | .B lock |
363 | is not used, the MTU may be updated by the kernel due to | |
a89d5329 | 364 | Path MTU Discovery. If the modifier |
761a1e60 CT |
365 | .B lock |
366 | is used, no path MTU discovery will be tried, all packets | |
367 | will be sent without the DF bit in IPv4 case or fragmented | |
368 | to MTU for IPv6. | |
369 | ||
370 | .TP | |
371 | .BI window " NUMBER" | |
372 | the maximal window for TCP to advertise to these destinations, | |
a89d5329 | 373 | measured in bytes. It limits maximal data bursts that our TCP |
761a1e60 CT |
374 | peers are allowed to send to us. |
375 | ||
376 | .TP | |
377 | .BI rtt " TIME" | |
378 | the initial RTT ('Round Trip Time') estimate. If no suffix is | |
379 | specified the units are raw values passed directly to the | |
380 | routing code to maintain compatibility with previous releases. | |
381 | Otherwise if a suffix of s, sec or secs is used to specify | |
382 | seconds and ms, msec or msecs to specify milliseconds. | |
383 | ||
384 | ||
385 | .TP | |
386 | .BI rttvar " TIME " "(2.3.15+ only)" | |
387 | the initial RTT variance estimate. Values are specified as with | |
388 | .BI rtt | |
389 | above. | |
390 | ||
391 | .TP | |
392 | .BI rto_min " TIME " "(2.6.23+ only)" | |
393 | the minimum TCP Retransmission TimeOut to use when communicating with this | |
a89d5329 | 394 | destination. Values are specified as with |
761a1e60 CT |
395 | .BI rtt |
396 | above. | |
397 | ||
398 | .TP | |
399 | .BI ssthresh " NUMBER " "(2.3.15+ only)" | |
400 | an estimate for the initial slow start threshold. | |
401 | ||
402 | .TP | |
403 | .BI cwnd " NUMBER " "(2.3.15+ only)" | |
a89d5329 | 404 | the clamp for congestion window. It is ignored if the |
761a1e60 CT |
405 | .B lock |
406 | flag is not used. | |
407 | ||
408 | .TP | |
409 | .BI initcwnd " NUMBER " "(2.5.70+ only)" | |
410 | the initial congestion window size for connections to this destination. | |
411 | Actual window size is this value multiplied by the MSS | |
412 | (``Maximal Segment Size'') for same connection. The default is | |
413 | zero, meaning to use the values specified in RFC2414. | |
414 | ||
415 | .TP | |
416 | .BI initrwnd " NUMBER " "(2.6.33+ only)" | |
417 | the initial receive window size for connections to this destination. | |
418 | Actual window size is this value multiplied by the MSS of the connection. | |
419 | The default value is zero, meaning to use Slow Start value. | |
420 | ||
29d1f730 FW |
421 | .TP |
422 | .BI features " FEATURES " (3.18+ only) | |
a89d5329 | 423 | Enable or disable per-route features. Only available feature at this |
29d1f730 FW |
424 | time is |
425 | .B ecn | |
426 | to enable explicit congestion notification when initiating connections to the | |
427 | given destination network. | |
428 | When responding to a connection request from the given network, ecn will | |
429 | also be used even if the | |
430 | .B net.ipv4.tcp_ecn | |
431 | sysctl is set to 0. | |
432 | ||
b37f2c89 CW |
433 | .TP |
434 | .BI quickack " BOOL " "(3.11+ only)" | |
435 | Enable or disable quick ack for connections to this destination. | |
436 | ||
6ef87f9c DB |
437 | .TP |
438 | .BI congctl " NAME " "(3.20+ only)" | |
439 | .TP | |
440 | .BI "congctl lock" " NAME " "(3.20+ only)" | |
441 | Sets a specific TCP congestion control algorithm only for a given destination. | |
442 | If not specified, Linux keeps the current global default TCP congestion control | |
443 | algorithm, or the one set from the application. If the modifier | |
444 | .B lock | |
445 | is not used, an application may nevertheless overwrite the suggested congestion | |
446 | control algorithm for that destination. If the modifier | |
447 | .B lock | |
448 | is used, then an application is not allowed to overwrite the specified congestion | |
449 | control algorithm for that destination, thus it will be enforced/guaranteed to | |
450 | use the proposed algorithm. | |
451 | ||
761a1e60 CT |
452 | .TP |
453 | .BI advmss " NUMBER " "(2.3.15+ only)" | |
454 | the MSS ('Maximal Segment Size') to advertise to these | |
a89d5329 | 455 | destinations when establishing TCP connections. If it is not given, |
761a1e60 CT |
456 | Linux uses a default value calculated from the first hop device MTU. |
457 | (If the path to these destination is asymmetric, this guess may be wrong.) | |
458 | ||
459 | .TP | |
460 | .BI reordering " NUMBER " "(2.3.15+ only)" | |
461 | Maximal reordering on the path to this destination. | |
462 | If it is not given, Linux uses the value selected with | |
463 | .B sysctl | |
464 | variable | |
465 | .BR "net/ipv4/tcp_reordering" . | |
466 | ||
467 | .TP | |
468 | .BI nexthop " NEXTHOP" | |
469 | the nexthop of a multipath route. | |
470 | .I NEXTHOP | |
471 | is a complex value with its own syntax similar to the top level | |
472 | argument lists: | |
473 | ||
474 | .in +8 | |
475 | .BI via " ADDRESS" | |
476 | - is the nexthop router. | |
477 | .sp | |
478 | ||
479 | .BI dev " NAME" | |
480 | - is the output device. | |
481 | .sp | |
482 | ||
483 | .BI weight " NUMBER" | |
484 | - is a weight for this element of a multipath | |
485 | route reflecting its relative bandwidth or quality. | |
486 | .in -8 | |
487 | ||
488 | .TP | |
489 | .BI scope " SCOPE_VAL" | |
490 | the scope of the destinations covered by the route prefix. | |
491 | .I SCOPE_VAL | |
492 | may be a number or a string from the file | |
493 | .BR "@SYSCONFDIR@/rt_scopes" . | |
494 | If this parameter is omitted, | |
495 | .B ip | |
496 | assumes scope | |
497 | .B global | |
498 | for all gatewayed | |
499 | .B unicast | |
500 | routes, scope | |
501 | .B link | |
502 | for direct | |
503 | .BR unicast " and " broadcast | |
504 | routes and scope | |
505 | .BR host " for " local | |
506 | routes. | |
507 | ||
508 | .TP | |
509 | .BI protocol " RTPROTO" | |
510 | the routing protocol identifier of this route. | |
511 | .I RTPROTO | |
512 | may be a number or a string from the file | |
513 | .BR "@SYSCONFDIR@/rt_protos" . | |
514 | If the routing protocol ID is not given, | |
515 | .B ip assumes protocol | |
516 | .B boot | |
517 | (i.e. it assumes the route was added by someone who doesn't | |
a89d5329 | 518 | understand what they are doing). Several protocol values have |
761a1e60 CT |
519 | a fixed interpretation. |
520 | Namely: | |
521 | ||
522 | .in +8 | |
523 | .B redirect | |
524 | - the route was installed due to an ICMP redirect. | |
525 | .sp | |
526 | ||
527 | .B kernel | |
528 | - the route was installed by the kernel during autoconfiguration. | |
529 | .sp | |
530 | ||
531 | .B boot | |
532 | - the route was installed during the bootup sequence. | |
533 | If a routing daemon starts, it will purge all of them. | |
534 | .sp | |
535 | ||
536 | .B static | |
537 | - the route was installed by the administrator | |
538 | to override dynamic routing. Routing daemon will respect them | |
539 | and, probably, even advertise them to its peers. | |
540 | .sp | |
541 | ||
542 | .B ra | |
543 | - the route was installed by Router Discovery protocol. | |
544 | .in -8 | |
545 | ||
546 | .sp | |
547 | The rest of the values are not reserved and the administrator is free | |
548 | to assign (or not to assign) protocol tags. | |
549 | ||
550 | .TP | |
551 | .B onlink | |
552 | pretend that the nexthop is directly attached to this link, | |
553 | even if it does not match any interface prefix. | |
61f541fe | 554 | .RE |
761a1e60 | 555 | |
61f541fe | 556 | .TP |
557 | ip route delete | |
558 | delete route | |
559 | .RS | |
761a1e60 CT |
560 | .B ip route del |
561 | has the same arguments as | |
562 | .BR "ip route add" , | |
563 | but their semantics are a bit different. | |
564 | ||
565 | Key values | |
566 | .RB "(" to ", " tos ", " preference " and " table ")" | |
a89d5329 | 567 | select the route to delete. If optional attributes are present, |
761a1e60 CT |
568 | .B ip |
569 | verifies that they coincide with the attributes of the route to delete. | |
570 | If no route with the given key and attributes was found, | |
571 | .B ip route del | |
572 | fails. | |
61f541fe | 573 | .RE |
761a1e60 | 574 | |
61f541fe | 575 | .TP |
576 | ip route show | |
577 | list routes | |
578 | .RS | |
761a1e60 CT |
579 | the command displays the contents of the routing tables or the route(s) |
580 | selected by some criteria. | |
581 | ||
582 | .TP | |
583 | .BI to " SELECTOR " (default) | |
584 | only select routes from the given range of destinations. | |
585 | .I SELECTOR | |
586 | consists of an optional modifier | |
587 | .RB "(" root ", " match " or " exact ")" | |
588 | and a prefix. | |
589 | .BI root " PREFIX" | |
590 | selects routes with prefixes not shorter than | |
591 | .IR PREFIX "." | |
592 | F.e. | |
593 | .BI root " 0/0" | |
594 | selects the entire routing table. | |
595 | .BI match " PREFIX" | |
596 | selects routes with prefixes not longer than | |
597 | .IR PREFIX "." | |
598 | F.e. | |
599 | .BI match " 10.0/16" | |
600 | selects | |
601 | .IR 10.0/16 "," | |
602 | .IR 10/8 " and " 0/0 , | |
603 | but it does not select | |
604 | .IR 10.1/16 " and " 10.0.0/24 . | |
605 | And | |
606 | .BI exact " PREFIX" | |
607 | (or just | |
608 | .IR PREFIX ")" | |
609 | selects routes with this exact prefix. If neither of these options | |
610 | are present, | |
611 | .B ip | |
612 | assumes | |
613 | .BI root " 0/0" | |
614 | i.e. it lists the entire table. | |
615 | ||
616 | .TP | |
617 | .BI tos " TOS" | |
1b3c149b | 618 | .TP |
761a1e60 CT |
619 | .BI dsfield " TOS" |
620 | only select routes with the given TOS. | |
621 | ||
622 | .TP | |
623 | .BI table " TABLEID" | |
a89d5329 | 624 | show the routes from this table(s). The default setting is to show table |
1b3c149b | 625 | .BR main "." |
761a1e60 CT |
626 | .I TABLEID |
627 | may either be the ID of a real table or one of the special values: | |
628 | .sp | |
629 | .in +8 | |
630 | .B all | |
631 | - list all of the tables. | |
632 | .sp | |
633 | .B cache | |
634 | - dump the routing cache. | |
635 | .in -8 | |
636 | ||
637 | .TP | |
638 | .B cloned | |
639 | .TP | |
640 | .B cached | |
641 | list cloned routes i.e. routes which were dynamically forked from | |
642 | other routes because some route attribute (f.e. MTU) was updated. | |
643 | Actually, it is equivalent to | |
644 | .BR "table cache" "." | |
645 | ||
646 | .TP | |
647 | .BI from " SELECTOR" | |
648 | the same syntax as for | |
649 | .BR to "," | |
650 | but it binds the source address range rather than destinations. | |
651 | Note that the | |
652 | .B from | |
653 | option only works with cloned routes. | |
654 | ||
655 | .TP | |
656 | .BI protocol " RTPROTO" | |
657 | only list routes of this protocol. | |
658 | ||
659 | .TP | |
660 | .BI scope " SCOPE_VAL" | |
661 | only list routes with this scope. | |
662 | ||
663 | .TP | |
664 | .BI type " TYPE" | |
665 | only list routes of this type. | |
666 | ||
667 | .TP | |
668 | .BI dev " NAME" | |
669 | only list routes going via this device. | |
670 | ||
671 | .TP | |
672 | .BI via " PREFIX" | |
673 | only list routes going via the nexthop routers selected by | |
674 | .IR PREFIX "." | |
675 | ||
676 | .TP | |
677 | .BI src " PREFIX" | |
678 | only list routes with preferred source addresses selected | |
679 | by | |
680 | .IR PREFIX "." | |
681 | ||
682 | .TP | |
683 | .BI realm " REALMID" | |
684 | .TP | |
685 | .BI realms " FROMREALM/TOREALM" | |
686 | only list routes with these realms. | |
61f541fe | 687 | .RE |
761a1e60 | 688 | |
61f541fe | 689 | .TP |
690 | ip route flush | |
691 | flush routing tables | |
692 | .RS | |
761a1e60 CT |
693 | this command flushes routes selected by some criteria. |
694 | ||
695 | .sp | |
696 | The arguments have the same syntax and semantics as the arguments of | |
697 | .BR "ip route show" , | |
a89d5329 | 698 | but routing tables are not listed but purged. The only difference is |
761a1e60 CT |
699 | the default action: |
700 | .B show | |
701 | dumps all the IP main routing table but | |
702 | .B flush | |
703 | prints the helper page. | |
704 | ||
705 | .sp | |
706 | With the | |
707 | .B -statistics | |
708 | option, the command becomes verbose. It prints out the number of | |
709 | deleted routes and the number of rounds made to flush the routing | |
710 | table. If the option is given | |
711 | twice, | |
712 | .B ip route flush | |
713 | also dumps all the deleted routes in the format described in the | |
714 | previous subsection. | |
61f541fe | 715 | .RE |
761a1e60 | 716 | |
61f541fe | 717 | .TP |
718 | ip route get | |
719 | get a single route | |
720 | .RS | |
761a1e60 CT |
721 | this command gets a single route to a destination and prints its |
722 | contents exactly as the kernel sees it. | |
723 | ||
724 | .TP | |
725 | .BI to " ADDRESS " (default) | |
726 | the destination address. | |
727 | ||
728 | .TP | |
729 | .BI from " ADDRESS" | |
730 | the source address. | |
731 | ||
732 | .TP | |
733 | .BI tos " TOS" | |
734 | .TP | |
735 | .BI dsfield " TOS" | |
736 | the Type Of Service. | |
737 | ||
738 | .TP | |
739 | .BI iif " NAME" | |
740 | the device from which this packet is expected to arrive. | |
741 | ||
742 | .TP | |
743 | .BI oif " NAME" | |
744 | force the output device on which this packet will be routed. | |
745 | ||
746 | .TP | |
747 | .B connected | |
748 | if no source address | |
749 | .RB "(option " from ")" | |
750 | was given, relookup the route with the source set to the preferred | |
751 | address received from the first lookup. | |
752 | If policy routing is used, it may be a different route. | |
753 | ||
754 | .P | |
755 | Note that this operation is not equivalent to | |
756 | .BR "ip route show" . | |
757 | .B show | |
758 | shows existing routes. | |
759 | .B get | |
a89d5329 | 760 | resolves them and creates new clones if necessary. Essentially, |
761a1e60 CT |
761 | .B get |
762 | is equivalent to sending a packet along this path. | |
763 | If the | |
764 | .B iif | |
765 | argument is not given, the kernel creates a route | |
766 | to output packets towards the requested destination. | |
767 | This is equivalent to pinging the destination | |
768 | with a subsequent | |
769 | .BR "ip route ls cache" , | |
a89d5329 | 770 | however, no packets are actually sent. With the |
761a1e60 CT |
771 | .B iif |
772 | argument, the kernel pretends that a packet arrived from this interface | |
773 | and searches for a path to forward the packet. | |
61f541fe | 774 | .RE |
761a1e60 | 775 | |
61f541fe | 776 | .TP |
777 | ip route save | |
778 | save routing table information to stdout | |
779 | .RS | |
780 | This command behaves like | |
761a1e60 CT |
781 | .BR "ip route show" |
782 | except that the output is raw data suitable for passing to | |
783 | .BR "ip route restore" . | |
61f541fe | 784 | .RE |
761a1e60 | 785 | |
61f541fe | 786 | .TP |
787 | ip route restore | |
788 | restore routing table information from stdin | |
789 | .RS | |
790 | This command expects to read a data stream as returned from | |
761a1e60 CT |
791 | .BR "ip route save" . |
792 | It will attempt to restore the routing table information exactly as | |
793 | it was at the time of the save, so any translation of information | |
a89d5329 PŠ |
794 | in the stream (such as device indexes) must be done first. Any existing |
795 | routes are left unchanged. Any routes specified in the data stream that | |
761a1e60 | 796 | already exist in the table will be ignored. |
61f541fe | 797 | .RE |
761a1e60 CT |
798 | |
799 | .SH EXAMPLES | |
800 | .PP | |
801 | ip ro | |
802 | .RS 4 | |
803 | Show all route entries in the kernel. | |
804 | .RE | |
805 | .PP | |
806 | ip route add default via 192.168.1.1 dev eth0 | |
807 | .RS 4 | |
808 | Adds a default route (for all addresses) via the local gateway 192.168.1.1 that can | |
809 | be reached on device eth0. | |
810 | .RE | |
811 | ||
812 | .SH SEE ALSO | |
813 | .br | |
814 | .BR ip (8) | |
815 | ||
816 | .SH AUTHOR | |
817 | Original Manpage by Michail Litvak <mci@owl.openwall.com> |