A bit crude but works
# Prerequisite: brew install ipcalc
# Place all the IP Addresses in a text file IPList.txt
echo "IP Address|Root Owner|Owner|IP CIDR|IP RDNS" | tee ARIN.txt
for ip in $(cat IPList.txt | sort); do
arin=$(whois -h whois.arin.net "$ip")
rootOwner=$(echo "$arin" | grep 'Organization' | cut -d ':' -f2 | sed 's/^[ \t]*//;s/[ \t]*$//')
# echo $rootOwner
Owner=$(whois -h whois.arin.net "n $ip" | tr '\n' '|' | cut -d '|' -f2 | cut -d '(' -f1 | sed 's/^[ \t]*//;s/[ \t]*$//' | grep -v 'CIDR')
ipCIDR=$(echo $(ipcalc $(echo $arin | grep 'NetRange' | cut -d ':' -f2 | sed 's/^[ \t]*//;s/[ \t]*$//') | grep -v deaggregate) | sed 's/^[ \t]*//;s/[ \t]*$//')
# echo $ipCIDR
ipRDNS=$(dig -x $ip | grep -v ';' | tr '\n' ' ' | awk -F" " '{print " "$5}' | sed 's/^[ \t]*//;s/[ \t]*$//')
echo "$ip|$rootOwner|$Owner|$ipCIDR|$ipRDNS"
done | tee -a ARIN.txt
Originally Posted on July 16, 2021
Last Updated on August 17, 2024
Last Updated on August 17, 2024
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.