Skip to content

Instantly share code, notes, and snippets.

@b4ldr
Created July 17, 2014 21:19
Show Gist options
  • Save b4ldr/25a0733a4cf141fc96f3 to your computer and use it in GitHub Desktop.
Save b4ldr/25a0733a4cf141fc96f3 to your computer and use it in GitHub Desktop.
b.root-servers.net:7 messages, 381787 size of messages wire , 588354 size of messages text, 5928 answers, 8154 records, wire size of records 437327, text size of records 800877
k.root-servers.net:21 messages, 343417 size of messages wire , 590167 size of messages text, 5654 answers, 8154 records, wire size of records 437327, text size of records 791013
c.root-servers.net:7 messages, 381787 size of messages wire , 588354 size of messages text, 5928 answers, 8154 records, wire size of records 437327, text size of records 800877
f.root-servers.net:7 messages, 381899 size of messages wire , 588354 size of messages text, 5932 answers, 8154 records, wire size of records 437327, text size of records 801021
g.root-servers.net:7 messages, 381787 size of messages wire , 588347 size of messages text, 5928 answers, 8154 records, wire size of records 437327, text size of records 800877
k.root-servers.net:21 messages, 343417 size of messages wire , 590167 size of messages text, 5654 answers, 8154 records, wire size of records 437327, text size of records 791013
lax.xfr.dns.icann.org:21 messages, 343417 size of messages wire , 590167 size of messages text, 5654 answers, 8154 records, wire size of records 437327, text size of records 791013
iad.xfr.dns.icann.org:21 messages, 343417 size of messages wire , 590167 size of messages text, 5654 answers, 8154 records, wire size of records 437327, text size of records 791013
import dns.query
import dns.zone
import dns.tsigkeyring
import dns.tsig
import socket
import sys
import StringIO
def get_stats(xfr):
zone = StringIO.StringIO()
zone_txt = StringIO.StringIO()
stats = {
'size' : 0,
'size_txt' : 0,
'size_msg' : 0,
'size_msg_txt' : 0,
'msg_count' : 0,
'rec_count' : 0,
'ans_count' : 0,
'add_count' : 0,
'ques_count' : 0,
'auth_count' : 0}
origin = dns.name.root
for message in xfr:
stats['auth_count'] += len(message.authority)
stats['add_count'] += len(message.additional)
stats['ques_count'] += len(message.question)
stats['ans_count'] += len(message.answer)
stats['size_msg'] += sys.getsizeof(message.to_wire(origin=origin))
stats['size_msg_txt'] += sys.getsizeof(message.to_text())
for ans in message.answer:
stats['rec_count'] += len(ans)
ans.to_wire(zone, origin=origin)
stats['size_txt'] += sys.getsizeof(ans.to_text())
stats['msg_count'] += 1
stats['size'] = sys.getsizeof(zone.getvalue())
return stats
for ip in ['192.228.79.201', '193.0.14.129', '192.33.4.12', '192.5.5.241', '192.112.36.4', '193.0.14.129',
'192.0.32.132', '192.0.47.132']:
stats = get_stats(dns.query.xfr(ip, '.'))
host = socket.gethostbyaddr(ip)[0]
print '{}:{} messages, {} size of messages wire , {} size of messages text, {} answers, {} records, wire size of records {}, text size of records {}'.format(host,
stats['msg_count'], stats['size_msg'], stats['size_msg_txt'],
stats['ans_count'], stats['rec_count'], stats['size'],
stats['size_txt'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment