commit: e5c3bb95ed454a270cf1796bc123fb0c8f34ab5a
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Wed Jan 27 16:25:05 2021 +0000
Commit: Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Wed Jan 27 16:55:21 2021 +0000
URL: https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=e5c3bb95
net/apipa.sh: Account for the first and last /24 being reserved
While the 169.254/16 prefix is used to define IPv4 link-local addresses,
RFC 3927 states that the first 256 and last 256 addresses are reserved for
future use. Therefore, the number of available addresses amounts to neither
64516 nor 65534, but actually 65024.
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>
net/apipa.sh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/apipa.sh b/net/apipa.sh
index f3ec534..41274fa 100644
--- a/net/apipa.sh
+++ b/net/apipa.sh
@@ -36,11 +36,11 @@ _random_apipa_octets()
seed=$(_random_bytes_as_int 2)
# For APIPA (RFC 3927), the 169.254.0.0/16 address block is
- # reserved. This provides 65534 addresses, having accounted for the
- # network and broadcast address. Note that we must count from 1.
+ # reserved. This provides 65024 addresses, having accounted for the
+ # fact that the first and last /24 are reserved for future use.
awk "BEGIN {
srand($seed)
- for (i=1; i<65535; i++) print rand() \" \" i
+ for (i=256; i<65280; i++) print rand() \" \" i
}" |
sort -k 1,1 -n |
POSIXLY_CORRECT=1 awk '{