Last Updated: September 30, 2021
·
229K
· barnettjw

Find all the IP ranges on an ASN

Here's a bash one-liner to find all the allocated IP ranges for an Automous System (ASN) given an IP address.

whois -h whois.radb.net -i origin -T route $(whois -h whois.radb.net <ip> | grep origin: | cut -d ' ' -f 6 | head -1) | grep -w "route:" | awk '{print $NF}' |sort -n

If you want to do this for your current public IP you can use:

whois -h whois.radb.net -i origin -T route $(whois -h whois.radb.net $(curl -s ifconfig.me/ip) | grep origin: | cut -d ' ' -f 6 | head -1) | grep -w "route:" | awk '{print $NF}' |sort -n

source: http://blog.wains.be/2010/12/30/find-ip-ranges-from-an-asn/