Skip to content

Instantly share code, notes, and snippets.

@zakird
Created April 22, 2014 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zakird/11196131 to your computer and use it in GitHub Desktop.
Save zakird/11196131 to your computer and use it in GitHub Desktop.
import sys
from cymru import CymruIPtoASNService
a = CymruIPtoASNService()
queries = []
with open(sys.argv[1]) as fd:
i = 0
for l in fd:
ip = l.lstrip().rstrip()
queries.append(ip)
i += 1
if i > 100:
for r in a.query(queries):
print r.as_number, r.country, r.as_name, r.bgp_prefix, r.ip_address
i = 0
queries = []
a = CymruIPtoASNService()
for r in a.query(queries):
print r.as_number, r.country, r.as_name, r.bgp_prefix, r.ip_address
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment