vm9hew
Last Updated: September 19, 2016
·
221.4K
· barnettjw
43ea08b4fc547e8a5da87c207bea2123

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/