1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
|
.TH "IP\-ADDRESS" 8 "20 Dec 2011" "iproute2" "Linux"
.SH "NAME"
ip-address \- protocol address management
.SH "SYNOPSIS"
.sp
.ad l
.in +8
.ti -8
.B ip
.RI "[ " OPTIONS " ]"
.B address
.RI " { " COMMAND " | "
.BR help " }"
.sp
.ti -8
.BR "ip address" " { " add " | " change " | " replace " } "
.IB IFADDR " dev " IFNAME
.RI "[ " LIFETIME " ] [ " CONFFLAG-LIST " ]"
.ti -8
.BR "ip address del"
.IB IFADDR " dev " IFNAME " [ " mngtmpaddr " ]"
.ti -8
.BR "ip address" " { " save " | " flush " } [ " dev
.IR IFNAME " ] [ "
.B scope
.IR SCOPE-ID " ] [ "
.B metric
.IR METRIC " ] [ "
.B to
.IR PREFIX " ] [ " FLAG-LIST " ] [ "
.B label
.IR PATTERN " ] [ " up " ]"
.ti -8
.BR "ip address" " [ " show " [ " dev
.IR IFNAME " ] [ "
.B scope
.IR SCOPE-ID " ] [ "
.B to
.IR PREFIX " ] [ " FLAG-LIST " ] [ "
.B label
.IR PATTERN " ] [ "
.B master
.IR DEVICE " ] [ "
.B type
.IR TYPE " ] [ "
.B vrf
.IR NAME " ] [ "
.BR up " ] ["
.BR nomaster " ]"
.B proto
.IR ADDRPROTO " ] ]"
.ti -8
.BR "ip address" " { " showdump " | " restore " }"
.ti -8
.IR IFADDR " := " PREFIX " | " ADDR
.B peer
.IR PREFIX " [ "
.B broadcast
.IR ADDR " ] [ "
.B anycast
.IR ADDR " ] [ "
.B label
.IR LABEL " ] [ "
.B scope
.IR SCOPE-ID " ] [ "
.B proto
.IR ADDRPROTO " ]"
.ti -8
.IR SCOPE-ID " := "
.RB "[ " host " | " link " | " global " | "
.IR NUMBER " ]"
.ti -8
.IR ADDRPROTO " := [ "
.IR NAME " | " NUMBER " ]"
.ti -8
.IR FLAG-LIST " := [ " FLAG-LIST " ] " FLAG
.ti -8
.IR FLAG " := ["
.RB [ - ] permanent " |"
.RB [ - ] dynamic " |"
.RB [ - ] secondary " |"
.RB [ - ] primary " |"
.RB [ - ] tentative " |"
.RB [ - ] deprecated " |"
.RB [ - ] dadfailed " |"
.RB [ - ] temporary " |"
.IR CONFFLAG-LIST " ]"
.ti -8
.IR CONFFLAG-LIST " := [ " CONFFLAG-LIST " ] " CONFFLAG
.ti -8
.IR CONFFLAG " := "
.RB "[ " home " | " mngtmpaddr " | " nodad " | " optimistic " | " noprefixroute " | " autojoin " ]"
.ti -8
.IR LIFETIME " := [ "
.BI valid_lft " LFT"
.RB "] [ " preferred_lft
.IR LFT " ]"
.ti -8
.IR LFT " := [ "
.BR forever " |"
.IR SECONDS " ]"
.ti -8
.IR TYPE " := [ "
.BR bridge " | "
.BR bridge_slave " |"
.BR bond " | "
.BR bond_slave " |"
.BR can " | "
.BR dummy " | "
.BR hsr " | "
.BR ifb " | "
.BR ipoib " |"
.BR macvlan " | "
.BR macvtap " | "
.BR vcan " | "
.BR veth " | "
.BR vlan " | "
.BR vxlan " |"
.BR ip6tnl " |"
.BR ipip " |"
.BR sit " |"
.BR gre " |"
.BR gretap " |"
.BR erspan " |"
.BR ip6gre " |"
.BR ip6gretap " |"
.BR ip6erspan " |"
.BR vti " |"
.BR vrf " |"
.BR nlmon " |"
.BR ipvlan " |"
.BR lowpan " |"
.BR geneve " |"
.BR macsec " |"
.BR netkit " ]"
.SH "DESCRIPTION"
The
.B address
is a protocol (IPv4 or IPv6) address attached
to a network device. Each device must have at least one address
to use the corresponding protocol. It is possible to have several
different addresses attached to one device. These addresses are not
discriminated, so that the term
.B alias
is not quite appropriate for them and we do not use it in this document.
.sp
The
.B ip address
command displays addresses and their properties, adds new addresses
and deletes old ones.
.SS ip address add - add new protocol address.
.TP
.BI dev " IFNAME "
the name of the device to add the address to.
.TP
.BI local " ADDRESS " (default)
the address of the interface. The format of the address depends
on the protocol. It is a dotted quad for IP and a sequence of
hexadecimal halfwords separated by colons for IPv6. The
.I ADDRESS
may be followed by a slash and a decimal number which encodes
the network prefix length.
.TP
.BI peer " ADDRESS"
the address of the remote endpoint for pointopoint interfaces.
Again, the
.I ADDRESS
may be followed by a slash and a decimal number, encoding the network
prefix length. If a peer address is specified, the local address
cannot have a prefix length. The network prefix is associated
with the peer rather than with the local address.
.TP
.BI broadcast " ADDRESS"
the broadcast address on the interface.
.sp
It is possible to use the special symbols
.B '+'
and
.B '-'
instead of the broadcast address. In this case, the broadcast address
is derived by setting/resetting the host bits of the interface prefix.
.TP
.BI label " LABEL"
Each address may be tagged with a label string.
The maximum allowed total length of label is 15 characters.
.TP
.BI scope " SCOPE_VALUE"
the scope of the area where this address is valid.
The available scopes are listed in
.BR @SYSCONF_USR_DIR@/rt_scopes " or " @SYSCONF_ETC_DIR@/rt_scopes
(has precedence if exists).
Predefined scope values are:
.in +8
.B global
- the address is globally valid.
.sp
.B site
- (IPv6 only, deprecated) the address is site local, i.e. it is
valid inside this site.
.sp
.B link
- the address is link local, i.e. it is valid only on this device.
.sp
.B host
- the address is valid only inside this host.
.in -8
.TP
.BI metric " NUMBER"
priority of prefix route associated with address.
.TP
.BI valid_lft " LFT"
the valid lifetime of this address; see section 5.5.4 of
RFC 4862. When it expires, the address is removed by the kernel.
Defaults to
.BR "forever" .
.TP
.BI preferred_lft " LFT"
the preferred lifetime of this address; see section 5.5.4
of RFC 4862. When it expires, the address is no longer used for new
outgoing connections. Defaults to
.BR "forever" .
.TP
.B home
(IPv6 only) designates this address the "home address" as defined in
RFC 6275.
.TP
.B mngtmpaddr
(IPv6 only) make the kernel manage temporary addresses created from this one as
template on behalf of Privacy Extensions (RFC3041). For this to become active,
the \fBuse_tempaddr\fP sysctl setting has to be set to a value greater than
zero. The given address needs to have a prefix length of 64. This flag allows
to use privacy extensions in a manually configured network, just like if
stateless auto-configuration was active.
.TP
.B nodad
(IPv6 only) do not perform Duplicate Address Detection (RFC 4862) when
adding this address.
.TP
.B optimistic
(IPv6 only) When performing Duplicate Address Detection, use the RFC 4429
optimistic variant.
.TP
.B noprefixroute
Do not automatically create a route for the network prefix of the added
address, and don't search for one to delete when removing the address. Changing
an address to add this flag will remove the automatically added prefix route,
changing it to remove this flag will create the prefix route automatically.
.TP
.B autojoin
Joining multicast groups on Ethernet level via
.B "ip maddr"
command does not work if connected to an Ethernet switch that does IGMP
snooping since the switch would not replicate multicast packets on ports that
did not have IGMP reports for the multicast addresses.
Linux VXLAN interfaces created via
.B "ip link add vxlan"
have the
.B group
option that enables them to do the required join.
Using the
.B autojoin
flag when adding a multicast address enables similar functionality for
Openvswitch VXLAN interfaces as well as other tunneling mechanisms that need to
receive multicast traffic.
.TP
.BI proto " ADDRPROTO"
the protocol identifier of this route.
.I ADDRPROTO
may be a number or a string from the file
.BR "/etc/iproute2/rt_addrprotos" .
If the protocol ID is not given,
.B ip assumes protocol 0. Several protocol
values have a fixed interpretation. Namely:
.in +8
.B kernel_lo
- The ::1 address that kernel installs on a loopback netdevice has this
protocol value
.sp
.B kernel_ra
- IPv6 addresses installed in response to router advertisement messages
.sp
.B kernel_ll
- Link-local addresses have this protocol value
.sp
.in -8
.sp
The rest of the values are not reserved and the administrator is free
to assign (or not to assign) protocol tags.
.SS ip address delete - delete protocol address
.B Arguments:
coincide with the arguments of
.B ip addr add.
The device name is a required argument. The rest are optional.
If no arguments are given, the first address is deleted.
.SS ip address show - look at protocol addresses
.TP
.BI dev " IFNAME " (default)
name of device.
.TP
.BI scope " SCOPE_VAL"
only list addresses with this scope.
.TP
.BI to " PREFIX"
only list addresses matching this prefix.
.TP
.BI label " PATTERN"
only list addresses with labels matching the
.IR "PATTERN" .
.I PATTERN
is a usual shell style pattern.
.TP
.BI master " DEVICE"
only list interfaces enslaved to this master device.
.TP
.BI vrf " NAME "
only list interfaces enslaved to this vrf.
.TP
.BI type " TYPE"
only list interfaces of the given type.
Note that the type name is not checked against the list of supported types -
instead it is sent as-is to the kernel. Later it is used to filter the returned
interface list by comparing it with the relevant attribute in case the kernel
didn't filter already. Therefore any string is accepted, but may lead to empty
output.
.TP
.B up
only list running interfaces.
.TP
.B nomaster
only list interfaces with no master.
.TP
.BR dynamic " and " permanent
(IPv6 only) only list addresses installed due to stateless
address configuration or only list permanent (not dynamic)
addresses. These two flags are inverses of each other, so
.BR -dynamic " is equal to " permanent " and "
.BR -permanent " is equal to " dynamic .
.TP
.B tentative
(IPv6 only) only list addresses which have not yet passed duplicate
address detection.
.TP
.B -tentative
(IPv6 only) only list addresses which are not in the process of
duplicate address detection currently.
.TP
.B deprecated
(IPv6 only) only list deprecated addresses.
.TP
.B -deprecated
(IPv6 only) only list addresses not being deprecated.
.TP
.B dadfailed
(IPv6 only) only list addresses which have failed duplicate
address detection.
.TP
.B -dadfailed
(IPv6 only) only list addresses which have not failed duplicate
address detection.
.TP
.BR temporary " or " secondary
List temporary IPv6 or secondary IPv4 addresses only. The Linux kernel shares a
single bit for those, so they are actually aliases for each other although the
meaning differs depending on address family.
.TP
.BR -temporary " or " -secondary
These flags are aliases for
.BR primary .
.TP
.B primary
List only primary addresses, in IPv6 exclude temporary ones. This flag is the
inverse of
.BR temporary " and " secondary .
.TP
.B -primary
This is an alias for
.BR temporary " or " secondary .
.TP
.BI proto " ADDRPROTO"
Only show addresses with a given protocol, or those for which the kernel
response did not include protocol. See the corresponding argument to
.B ip addr add
for details about address protocols.
.SS ip address flush - flush protocol addresses
This command flushes the protocol addresses selected by some criteria.
.PP
This command has the same arguments as
.BR show " except that " type " and " master " selectors are not supported."
Another difference is that it does not run when no arguments are given.
.PP
.B Warning:
This command and other
.B flush
commands are unforgiving. They will cruelly purge all the addresses.
.PP
With the
.B -statistics
option, the command becomes verbose. It prints out the number of deleted
addresses and the number of rounds made to flush the address list.
If this option is given twice,
.B ip address flush
also dumps all the deleted addresses in the format described in the
previous subsection.
.SH "EXAMPLES"
.PP
ip address show
.RS 4
Shows IPv4 and IPv6 addresses assigned to all network interfaces. The 'show'
subcommand can be omitted.
.RE
.PP
ip address show up
.RS 4
Same as above except that only addresses assigned to active network interfaces
are shown.
.RE
.PP
ip address show dev eth0
.RS 4
Shows IPv4 and IPv6 addresses assigned to network interface eth0.
.RE
.PP
ip address add 2001:0db8:85a3::0370:7334/64 dev eth1
.RS 4
Adds an IPv6 address to network interface eth1.
.RE
.PP
ip address delete 2001:0db8:85a3::0370:7334/64 dev eth1
.RS 4
Delete the IPv6 address added above.
.RE
.PP
ip address flush dev eth4 scope global
.RS 4
Removes all global IPv4 and IPv6 addresses from device eth4. Without 'scope
global' it would remove all addresses including IPv6 link-local ones.
.RE
.SH SEE ALSO
.br
.BR ip (8)
.SH AUTHOR
Original Manpage by Michail Litvak <mci@owl.openwall.com>
|