aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKerin Millar <kfm@plushkava.net>2021-01-27 16:25:05 +0000
committerLars Wendler <polynomial-c@gentoo.org>2021-01-27 17:55:21 +0100
commite5c3bb95ed454a270cf1796bc123fb0c8f34ab5a (patch)
treed908231401c0f8f4210f7f04088e844ae2feb5a4
parentnet/iwd.sh: Removed non-working "need dbus" call (diff)
downloadnetifrc-e5c3bb95ed454a270cf1796bc123fb0c8f34ab5a.tar.gz
netifrc-e5c3bb95ed454a270cf1796bc123fb0c8f34ab5a.tar.bz2
netifrc-e5c3bb95ed454a270cf1796bc123fb0c8f34ab5a.zip
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@plushkava.net> Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
-rw-r--r--net/apipa.sh6
1 files 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 '{