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
Solution 1:
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('==============')
Solution 2:
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
Solution 3:
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)
Post a Comment for "BGP ASN Lookup With Python"