Skip to content

Instantly share code, notes, and snippets.

@rajbot
Created December 31, 2014 23:30
Show Gist options
  • Save rajbot/b8f4459e721b54f65582 to your computer and use it in GitHub Desktop.
Save rajbot/b8f4459e721b54f65582 to your computer and use it in GitHub Desktop.
Query DNS servers to see which ones are blocking archive.org
import dns.resolver
from dns.exception import Timeout
import json
import time
f = open('in.json')
ips = json.load(f)
good = set()
bad = set()
timeout = set()
res = dns.resolver.Resolver()
res.timeout = 2
res.lifetime = 2
for ip in ips:
if ip['state'] != 'valid':
continue
res.nameservers = [ip['ip']]
print 'checking', ip['ip']
try:
a = res.query('archive.org')
except Timeout:
timeout.add(ip['ip'])
print ' timeout'
continue
except Exception:
print ' fail'
continue
for rdata in a:
if rdata.address == '207.241.224.2':
good.add(ip['ip'])
else:
bad.add(ip['ip'])
print ' BAD', ip['ip']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment