Here is a script that is intended to generate a series of IPv4 addresses in CIDR/16 address space:

 counter=1
while [ $counter -le 4096 ]
do prefix=185.180; dd if=/dev/urandom bs=2 count=1 2>/dev/null | od -An -tu1 | tr -s ' ' . | sed s/^/$prefix/ >> Temp42120Works.txt
((counter++))
done

The script produces a list of 4,096 IPv4 addresses, each of which starts with 185.180, in about ten seconds. It works OK in the Mate terminal, but not when I invoke bash (/bin/sh), which doesn't
like counter++ and fails to stop generating IPv4 addresses as a result.

The following code is an effort to expand the scope of the task to encompass an entire list of
differently prefixed addresses:

retnuoc=0
while [ "retnuoc" -le 26 ]
do NUM=$(`expr $retnuoc + 1`)
counter=1
while [ "$counter" -le 4 ]
prefix=`expr tail -n+$NUM SS.IPv4-NLU-January2020-26Prefixes.txt | head -n1`;
dd if=/dev/urandom bs=2 count=1 2>/dev/null | od -An -tu1 | tr -s ' ' . | sed s/^/$prefix/ >> Temp41921F13.txt
counter=$(`expr $counter + 1`)
done
retnuoc=$(`expr $retnuocm+ 1`)
done

The first two octets are contained in the file SS.IPv4-NLU-January2020-26Prefixes.txt (attached)
and extracted with the expression
tail -n+NUM SS.IPv4-NLU-January2020-26Prefixes.txt | head -n1
which works OK when NUM is replaced by a number between 1 and 26 (in the present example).

The second pair of octets is randomly generated with this expression wherein $NUM is replaced by an
exemplar octet pair:
prefix=185.39; dd if=/dev/urandom bs=2 count=1 2>/dev/null | od -An -tu1 | tr -s ' ' . | sed s/^/$prefix/

Alas, progress has stalled now that the script no longer produces complaints of syntax errors. If it were to work, 104 IPv4 addresses would be forthcoming, four for each of the twenty six
octet pairs.

George Langford

99.79
99.192
98.25
98.187
98.162
97.107
96.9
96.44
96.30
96.2
96.114
95.90
95.86
95.85
95.84
95.80
95.73
95.72
95.71
95.70
95.67
95.66
95.64
95.58
95.47
95.46

Reply via email to