I want to know what IP ranges are belonging for example to the AS714.

How do I get this information?

I know how to do the reverse way, which is easy with whois. But the other way doesn't seem to be that easy.

  • Do you want IP address ranges that originate on this AS? (Direct customers who don't have an AS) What about IP address ranges only reachable through this AS? (Customers that have their own AS.) What about IP address ranges reachable through this AS but also other provider ASes? (Multihomed customers.) – David Schwartz Mar 28 '12 at 10:06
  • 1
    The purpose was to find out all the IP ranges my provider owns. I got this info by visiting bgp.potaroo.net/as1221/asnames.txt in order to find out the AS number and ripe.net/data-tools/stats/ris/routing-information-service in order to get all the IP ranges through the prefixes tab. Do you know other possibilities? – JohnnyFromBF Mar 28 '12 at 11:01

They're listed online with related details at http://ipinfo.io/AS714 (replace the ASN to get the equivalent details for any other ASN).

If instead of browsing them you'd rather grab them programmatically you can use the RADb whois server:

$ whois -h whois.radb.net -- '-i origin AS714' | grep -Eo "([0-9.]+){4}/[0-9]+" | head
| improve this answer | |

Ok, I just found one simple way. You just put this http://bgp.he.net/[ASXXX]#_prefixes in your browser, where [ASXXX] is a certain AS and a number like this http://bgp.he.net/AS714#_prefixes.

| improve this answer | |

For anyone else who finds this - I really liked Ben Dowling’s answer. However according to:


There is a different way which also yields very different results! I was testing a facebook IP which didn't come up in Bens' | head results. According to the above link the correct way of querying for IP4 addresses would be:

whois -h whois.radb.net '!gas714'

Equally as nice is the fact you can now find all IP6 addresses with:

whois -h whois.radb.net '!6as714'

As I say - when I ran this for the Facebook ASN I found my missing IP address.

Later update

Unfortunately Radb.net does not give out the correct data!! Try ASN 19281 for example and you'll see results given but if you simply whois radb.net with no parameters it will say “No records found.” It doesn't seem accurate enough IMHO.

| improve this answer | |
  • This method does have some troubles with long lists, like Facebook's ie. whois -h whois.radb.net -- '!6as32934' that gets "clipped" with a new-line in the middle of the addresses – Hvisage Jun 26 '18 at 17:40
  • which means you should rather use nc, as in: echo '!6as32934'|nc whois.radb.net 43 – Hvisage Jun 26 '18 at 17:49

I found that you can't really automate queries to bgp.he.net, I kept getting 403 responses, and then when I faked a user agent, it tried to verify that I was indeed a real browser. I kind of failed in everything with bgp.he.net (even contacting the site).

What DID work for me, was to query http://ipinfo.io as Ben Dowling said in another answer.

I did a python script to get every IP block per ASN. I had a list of every AS number in a csv file. here it is:

import requests
from bs4 import BeautifulSoup
import re

url_base = 'http://ipinfo.io/'
as_base = 'AS'

output = open('ip_per_asn.csv', 'w')
with open('chilean_asn.csv') as f:
    lines = f.read().splitlines()
    for asn in lines:
        ASN = as_base + asn
        page = requests.get(url_base+ASN)
        html_doc = page.content
        soup = BeautifulSoup(html_doc, 'html.parser')
        for link in soup.find_all('a'):
            if asn in link.get('href'):
                auxstring = '/'+as_base+asn+'/'
                line = re.sub(auxstring, '', link.get('href'))
                printstring = asn+','+line+'\n'
                if 'AS' not in printstring:
        print asn+'\n'

print 'script finished'

That said, you can also use curl with ipinfo.io. Just try to be polite and don't make absurdly large queries to the servers.

| improve this answer | |

An even easier way to get this information for say "19281" from: https://ipinfo.io/AS19281

grep with regex

ASN="19281"; curl -s https://ipinfo.io/AS${ASN} |grep -Eo "((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/(3[0-2]|[1-2][0-9]|[0-9]))$)" |sort -Vu


[root@cpanel ~]# ASN="19281"; curl -s https://ipinfo.io/AS${ASN} |grep -Eo "((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/(3[0-2]|[1-2][0-9]|[0-9]))$)" |sort -Vu
[root@cpanel ~]#

For say Facebook: https://ipinfo.io/AS32934

can see how effective this method is.

[root@cpanel ~]# ASN="32934"; curl -s https://ipinfo.io/AS${ASN} |grep -Eo "((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/(3[0-2]|[1-2][0-9]|[0-9]))$)" |sort -Vu
[root@cpanel ~]#

Hope this helps someone out.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.