gamarga
gamarga

Reputation: 105

BGP ASN Lookup with Python

Does anyone know of a Python module or a solution for how I could lookup company info (Name preferably) via the ASN (autonomous system number) number?

There are lots of IP to ASN tools but that is not what I require.

ASN needs to be the input - company name output.

This website has the sort of info I need: http://bgp.potaroo.net/cgi-bin/as-report?as=AS5607&view=2.0

Any ideas are appreciated!

Upvotes: 3

Views: 9314

Answers (3)

Pedro Lobito
Pedro Lobito

Reputation: 99001

A slightly updated version of @Al-Pha answer:

Multi lookup:

from cymruwhois import Client
import socket

c = Client()
ip = socket.gethostbyname('globalresearch.ca')
for r in c.lookupmany([ip, "213.73.91.35"]):
    print(r.__dict__)
    # print(r.asn)

Single lookup:

c = Client()
r = c.lookup("213.73.91.35")
print(r.asn)

Upvotes: 0

Al Pha
Al Pha

Reputation: 21

Try this, it's maybe what you need

from cymruwhois import Client
import ipresolved
domain='facebook.com'
ips=ipresolved.getipresolvedfromdomain(domain)
c=Client()
for i in ips.json()['resolutions']:
    ip=i['ip_address']
    print('ip : '+ip)
    r=c.lookup(ip)
    print('asn number: ',r.asn)
    print('asn owener : ',r.owner)
    print('==============')

Upvotes: 2

A-y
A-y

Reputation: 793

That information is available publicly on the CIDR-Report website.

This url has all the info you need and is updated daily. Big file, it might take a while to load : http://www.cidr-report.org/as2.0/autnums.html

Upvotes: 1

Related Questions