Skip to content

Instantly share code, notes, and snippets.

@hackingbutlegal
Created October 8, 2014 19:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hackingbutlegal/8385da22c63840bdefe4 to your computer and use it in GitHub Desktop.
Save hackingbutlegal/8385da22c63840bdefe4 to your computer and use it in GitHub Desktop.
Enumerate a CIDR
ip=$( echo $1 | cut -d"/" -f1 )
no=$( echo $1 | cut -d"/" -f2 )
k=`expr 32 - $no`
nu=$(echo "2 ^ $k" | bc)
num=1
new_ip=$( echo $ip | cut -d"." -f1-3 )
while [[ $num -ne $nu ]]
do
echo $new_ip".$num"
(( num = num + 1 ))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment