Last active
May 27, 2016 12:27
-
-
Save hellais/6833969f10067ac7748c to your computer and use it in GitHub Desktop.
IP to ASN
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# To get GeoIPASNum.dat: | |
# wget https://geolite.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz && gunzip GeoIPASNum.dat.gz | |
import sys | |
import pygeoip | |
if len(sys.argv) < 2: | |
print "Usage: path/to/GeoIPASNum.dat [IPs ... ...]" | |
ips = sys.argv[2:] | |
gi = pygeoip.GeoIP(sys.argv[1]) | |
for ip in ips: | |
print gi.asn_by_name(ip) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment