Commit 4e972d5e authored by Pavel Šimerda's avatar Pavel Šimerda Committed by Stephen Hemminger

ip-address: fix and extend documentation

 * Improve manual page synopsis and built-it help
 * Use full subcommand names (e.g. 'address' and 'maddress')
 * Specify when IPv4, IPv6 or both are affected
 * Add lifetimes, home and nodad
 * Remove any remaining excess spaces

Commit 43d29f78 substantially improves generated ip-address.8 instead of
ip-address.8.in and commit e419f2d6 removes the generated one losing the
improvements entirely. This commit recovers the lost changes, adapts
them to the current manual page and adds more man page and help
improvements.

Original commit by: Kenyon Ralph <kenyon@kenyonralph.com>
parent 503aa4e2
...@@ -71,15 +71,15 @@ static void usage(void) ...@@ -71,15 +71,15 @@ static void usage(void)
if (do_link) { if (do_link) {
iplink_usage(); iplink_usage();
} }
fprintf(stderr, "Usage: ip addr {add|change|replace} IFADDR dev STRING [ LIFETIME ]\n"); fprintf(stderr, "Usage: ip address {add|change|replace} IFADDR dev IFNAME [ LIFETIME ]\n");
fprintf(stderr, " [ CONFFLAG-LIST ]\n"); fprintf(stderr, " [ CONFFLAG-LIST ]\n");
fprintf(stderr, " ip addr del IFADDR dev STRING [mngtmpaddr]\n"); fprintf(stderr, " ip address del IFADDR dev IFNAME [mngtmpaddr]\n");
fprintf(stderr, " ip addr {show|save|flush} [ dev STRING ] [ scope SCOPE-ID ]\n"); fprintf(stderr, " ip address {show|save|flush} [ dev IFNAME ] [ scope SCOPE-ID ]\n");
fprintf(stderr, " [ to PREFIX ] [ FLAG-LIST ] [ label PATTERN ] [up]\n"); fprintf(stderr, " [ to PREFIX ] [ FLAG-LIST ] [ label LABEL ] [up]\n");
fprintf(stderr, " ip addr {showdump|restore}\n"); fprintf(stderr, " ip address {showdump|restore}\n");
fprintf(stderr, "IFADDR := PREFIX | ADDR peer PREFIX\n"); fprintf(stderr, "IFADDR := PREFIX | ADDR peer PREFIX\n");
fprintf(stderr, " [ broadcast ADDR ] [ anycast ADDR ]\n"); fprintf(stderr, " [ broadcast ADDR ] [ anycast ADDR ]\n");
fprintf(stderr, " [ label STRING ] [ scope SCOPE-ID ]\n"); fprintf(stderr, " [ label IFNAME ] [ scope SCOPE-ID ]\n");
fprintf(stderr, "SCOPE-ID := [ host | link | global | NUMBER ]\n"); fprintf(stderr, "SCOPE-ID := [ host | link | global | NUMBER ]\n");
fprintf(stderr, "FLAG-LIST := [ FLAG-LIST ] FLAG\n"); fprintf(stderr, "FLAG-LIST := [ FLAG-LIST ] FLAG\n");
fprintf(stderr, "FLAG := [ permanent | dynamic | secondary | primary |\n"); fprintf(stderr, "FLAG := [ permanent | dynamic | secondary | primary |\n");
...@@ -1126,7 +1126,7 @@ static int ipadd_dump_check_magic(void) ...@@ -1126,7 +1126,7 @@ static int ipadd_dump_check_magic(void)
__u32 magic = 0; __u32 magic = 0;
if (isatty(STDIN_FILENO)) { if (isatty(STDIN_FILENO)) {
fprintf(stderr, "Can't restore addr dump from a terminal\n"); fprintf(stderr, "Can't restore address dump from a terminal\n");
return -1; return -1;
} }
...@@ -1878,6 +1878,6 @@ int do_ipaddr(int argc, char **argv) ...@@ -1878,6 +1878,6 @@ int do_ipaddr(int argc, char **argv)
return ipaddr_restore(); return ipaddr_restore();
if (matches(*argv, "help") == 0) if (matches(*argv, "help") == 0)
usage(); usage();
fprintf(stderr, "Command \"%s\" is unknown, try \"ip addr help\".\n", *argv); fprintf(stderr, "Command \"%s\" is unknown, try \"ip address help\".\n", *argv);
exit(-1); exit(-1);
} }
...@@ -14,18 +14,26 @@ ip-address \- protocol address management ...@@ -14,18 +14,26 @@ ip-address \- protocol address management
.sp .sp
.ti -8 .ti -8
.BR "ip address" " { " add " | " del " } " .BR "ip address" " { " add " | " change " | " replace " } "
.IB IFADDR " dev " STRING .IB IFADDR " dev " IFNAME
.RI "[ " LIFETIME " ] [ " CONFFLAG-LIST " ]"
.ti -8 .ti -8
.BR "ip address" " { " show " | " flush " } [ " dev .BR "ip address del"
.IR STRING " ] [ " .IB IFADDR " dev " IFNAME " [ " mngtmpaddr " ]"
.ti -8
.BR "ip address" " { " show " | " save " | " flush " } [ " dev
.IR IFNAME " ] [ "
.B scope .B scope
.IR SCOPE-ID " ] [ " .IR SCOPE-ID " ] [ "
.B to .B to
.IR PREFIX " ] [ " FLAG-LIST " ] [ " .IR PREFIX " ] [ " FLAG-LIST " ] [ "
.B label .B label
.IR PATTERN " ]" .IR PATTERN " ] [ " up " ]"
.ti -8
.BR "ip address" " { " showdump " | " restore " }"
.ti -8 .ti -8
.IR IFADDR " := " PREFIX " | " ADDR .IR IFADDR " := " PREFIX " | " ADDR
...@@ -36,7 +44,7 @@ ip-address \- protocol address management ...@@ -36,7 +44,7 @@ ip-address \- protocol address management
.B anycast .B anycast
.IR ADDR " ] [ " .IR ADDR " ] [ "
.B label .B label
.IR STRING " ] [ " .IR LABEL " ] [ "
.B scope .B scope
.IR SCOPE-ID " ]" .IR SCOPE-ID " ]"
...@@ -52,15 +60,33 @@ ip-address \- protocol address management ...@@ -52,15 +60,33 @@ ip-address \- protocol address management
.IR FLAG " := " .IR FLAG " := "
.RB "[ " permanent " | " dynamic " | " secondary " | " primary " | \ .RB "[ " permanent " | " dynamic " | " secondary " | " primary " | \
[ - ] " tentative " | [ - ] " deprecated " | [ - ] " dadfailed " | "\ [ - ] " tentative " | [ - ] " deprecated " | [ - ] " dadfailed " | "\
temporary " ]" temporary " ] " CONFFLAG-LIST " ]"
.ti -8
.IR CONFFLAG-LIST " := [ " CONFFLAG-LIST " ] " CONFFLAG
.ti -8
.IR CONFFLAG " := "
.RB "[ " home " | " nodad " ]"
.ti -8
.IR LIFETIME " := [ "
.BI valid_lft " LFT"
.RB "| " preferred_lft
.IR LFT " ]"
.ti -8
.IR LFT " := [ "
.BR forever " |"
.IR SECONDS " ]"
.SH "DESCRIPTION" .SH "DESCRIPTION"
The The
.B address .B address
is a protocol (IP or IPv6) address attached is a protocol (IPv4 or IPv6) address attached
to a network device. Each device must have at least one address to a network device. Each device must have at least one address
to use the corresponding protocol. It is possible to have several to use the corresponding protocol. It is possible to have several
different addresses attached to one device. These addresses are not different addresses attached to one device. These addresses are not
discriminated, so that the term discriminated, so that the term
.B alias .B alias
is not quite appropriate for them and we do not use it in this document. is not quite appropriate for them and we do not use it in this document.
...@@ -73,7 +99,7 @@ and deletes old ones. ...@@ -73,7 +99,7 @@ and deletes old ones.
.SS ip address add - add new protocol address. .SS ip address add - add new protocol address.
.TP .TP
.BI dev " NAME" .BI dev " IFNAME "
the name of the device to add the address to. the name of the device to add the address to.
.TP .TP
...@@ -107,7 +133,7 @@ instead of the broadcast address. In this case, the broadcast address ...@@ -107,7 +133,7 @@ instead of the broadcast address. In this case, the broadcast address
is derived by setting/resetting the host bits of the interface prefix. is derived by setting/resetting the host bits of the interface prefix.
.TP .TP
.BI label " NAME" .BI label " LABEL"
Each address may be tagged with a label string. Each address may be tagged with a label string.
In order to preserve compatibility with Linux-2.0 net aliases, In order to preserve compatibility with Linux-2.0 net aliases,
this string must coincide with the name of the device or must be prefixed this string must coincide with the name of the device or must be prefixed
...@@ -125,7 +151,7 @@ Predefined scope values are: ...@@ -125,7 +151,7 @@ Predefined scope values are:
- the address is globally valid. - the address is globally valid.
.sp .sp
.B site .B site
- (IPv6 only) the address is site local, i.e. it is - (IPv6 only, deprecated) the address is site local, i.e. it is
valid inside this site. valid inside this site.
.sp .sp
.B link .B link
...@@ -135,6 +161,30 @@ valid inside this site. ...@@ -135,6 +161,30 @@ valid inside this site.
- the address is valid only inside this host. - the address is valid only inside this host.
.in -8 .in -8
.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 nodad
(IPv6 only) do not perform Duplicate Address Detection (RFC 4862) when
adding this address.
.SS ip address delete - delete protocol address .SS ip address delete - delete protocol address
.B Arguments: .B Arguments:
coincide with the arguments of coincide with the arguments of
...@@ -145,7 +195,7 @@ If no arguments are given, the first address is deleted. ...@@ -145,7 +195,7 @@ If no arguments are given, the first address is deleted.
.SS ip address show - look at protocol addresses .SS ip address show - look at protocol addresses
.TP .TP
.BI dev " NAME " (default) .BI dev " IFNAME " (default)
name of device. name of device.
.TP .TP
...@@ -219,36 +269,53 @@ The difference is that it does not run when no arguments are given. ...@@ -219,36 +269,53 @@ The difference is that it does not run when no arguments are given.
.PP .PP
.B Warning: .B Warning:
This command (and other This command and other
.B flush .B flush
commands described below) is pretty dangerous. If you make a mistake, commands are unforgiving. They will cruelly purge all the addresses.
it will not forgive it, but will cruelly purge all the addresses.
.PP .PP
With the With the
.B -statistics .B -statistics
option, the command becomes verbose. It prints out the number of deleted 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 addresses and the number of rounds made to flush the address list.
this option is given twice, If this option is given twice,
.B ip address flush .B ip address flush
also dumps all the deleted addresses in the format described in the also dumps all the deleted addresses in the format described in the
previous subsection. previous subsection.
.SH "EXAMPLES" .SH "EXAMPLES"
.PP .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 ip address show dev eth0
.RS 4 .RS 4
Shows the addresses assigned to network interface eth0 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 .RE
.PP .PP
ip addr add 2001:0db8:85a3::0370:7334/64 dev eth1 ip address delete 2001:0db8:85a3::0370:7334/64 dev eth1
.RS 4 .RS 4
Adds an IPv6 address to network interface eth1 Delete the IPv6 address added above.
.RE .RE
.PP .PP
ip addr flush dev eth4 ip address flush dev eth4 scope global
.RS 4 .RS 4
Removes all addresses from device eth4 Removes all global IPv4 and IPv6 addresses from device eth4. Without 'scope
global' it would remove all addresses including IPv6 link-local ones.
.RE .RE
.SH SEE ALSO .SH SEE ALSO
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment