Last active
August 20, 2022 20:41
-
-
Save KaraRyougi/cf16a66d5ff79507589662e5893d760c to your computer and use it in GitHub Desktop.
find blocks in 103/8 that has not been allocated
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get ipv4 allocation records from rex.apnic.net | |
# rename it to apnic_ipv4.csv | |
grep -o ',"103.\+","2."' apnic_ipv4.csv | sed 's/,"//' | sed 's/","/\//' | sed 's/"$//' | sort -t . -k 1,1n -k 2,2n -k 3,3n | gawk -F '.' '{ printf "0x%x%s\n", lshift($2, 8) + $3, $4}' | sed 's/0\//\//' | gawk --non-decimal-data -F '/' '{ for (i = 1; i <= lshift(1, 24-$2); i++) printf "%d\n", $1+i-1 }' > final | |
seq 0x100 0xffff > total | |
diff --side-by-side --suppress-common-lines total final | gawk '{ printf "%x\n",lshift(103,24) + lshift($1,8) }' | gawk --non-decimal-data '{for (i=1;i<=NF;i++) printf "%d%s","0x"$i,(i==NF?"\n":".")}' FPAT='..' | sed 's/$/\/24/' > unallocated_ip.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment