Last active
February 15, 2017 20:07
-
-
Save 0x9900/4454974 to your computer and use it in GitHub Desktop.
Quick and dirty speed test for public DNS services.
This file contains 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 | |
# | |
import DNS | |
import time | |
import sys | |
from collections import defaultdict | |
services = { | |
#'local': ['192.168.10.1'], | |
'Google': ['8.8.8.8', '8.8.4.4'], | |
'OpenDNS': ['208.67.222.222', '208.67.220.220'], | |
'Norton': ['198.153.192.1', '198.153.194.1'], | |
'Verizon': ['4.2.2.1', '4.2.2.2', '4.2.2.3', '4.2.2.4', '4.2.2.5', | |
'4.2.2.6'], | |
'Level3': ['209.244.0.3', '209.244.0.4'], | |
'Securly': ['184.169.143.224', '184.169.161.155'], | |
'Comodo Secure DNS': ['8.26.56.26', '8.20.247.20'], | |
'DNS Advantage': ['156.154.70.1', '156.154.71.1'], | |
'Norton ConnectSafe': ['198.153.192.40', '198.153.194.40'], | |
'OpenNIC': ['74.207.247.4', '64.0.55.201'], | |
'SmartViper': ['208.76.50.50', '208.76.51.51'], | |
} | |
requests = ( | |
'bakdlkkd.tz', | |
'dlkdkdkd.il', | |
'duckduckgo.com', | |
'klsilkkd.cn', | |
'twitter.com', | |
'www.bing.com', | |
'www.cnn.com', | |
'www.dropbox.com', | |
'www.facebook.com', | |
'www.google.com', | |
'www.huffingtonpost.com', | |
'www.msnbc.com', | |
'www.yahoo.com', | |
) | |
def benchmark(server): | |
DNS.defaults['server'] = [ server ] | |
start = time.time() | |
for host in requests: | |
try: | |
DNS.dnslookup(host, 'A') | |
except DNS.ServerError: # the domain is not found | |
pass | |
except (DNS.TimeoutError, DNS.SocketError): # cannot connect to the DNS | |
return -1 | |
end = time.time() - start | |
return end | |
def run(): | |
print 'Collecting data:', | |
sys.stdout.flush() | |
response_times = defaultdict(list) | |
for service, servers in services.iteritems(): | |
for server_ip in servers: | |
bench = benchmark(server_ip) | |
if bench > 0.0: | |
response_times[service].append(bench) | |
print '.', | |
sys.stdout.flush() | |
return response_times | |
if __name__ == '__main__': | |
results = run() | |
namelen = max([len(s) for s in results.keys()]) | |
output = "%%%ds\t%%0.3f\t%%s" % (namelen + 2) | |
for service, bench in results.iteritems(): | |
print output % (service, sum(bench) / float(len(bench)), | |
["%.3f" % r for r in bench]) |
This file contains 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
# results taken from different locations (network providers) in california | |
# | |
fred:src$ python ./dnstest.py | |
Collecting data: . . . . . . . . . . . | |
Securly 0.389 ['0.551', '0.228'] | |
Comodo Secure DNS 0.593 ['0.795', '0.390'] | |
SmartViper 1.586 ['1.694', '1.478'] | |
Verizon 0.516 ['0.350', '0.626', '0.409', '0.422', '0.418', '0.870'] | |
OpenDNS 0.301 ['0.301'] | |
Level3 0.333 ['0.334', '0.332'] | |
Google 0.454 ['0.520', '0.387'] | |
OpenNIC 0.631 ['0.143', '1.119'] | |
Norton ConnectSafe 0.273 ['0.113', '0.433'] | |
Norton 0.320 ['0.329', '0.311'] | |
DNS Advantage 0.614 ['1.046', '0.182'] | |
-bash-4.2$ python2.7 dnstest.py | |
Collecting data: . . . . . . . . . . . . | |
Securly 0.471 ['0.296', '0.646'] | |
Comodo Secure DNS 0.400 ['0.440', '0.361'] | |
SmartViper 1.198 ['1.225', '1.171'] | |
Verizon 0.143 ['0.124', '0.080', '0.081', '0.083', '0.079', '0.408'] | |
OpenDNS 0.093 ['0.077', '0.109'] | |
Level3 0.100 ['0.091', '0.109'] | |
Google 0.248 ['0.396', '0.101'] | |
OpenNIC 0.626 ['0.121', '1.132'] | |
Norton ConnectSafe 1.013 ['0.183', '1.843'] | |
Norton 0.102 ['0.102'] | |
DNS Advantage 0.428 ['0.778', '0.077'] | |
local 0.051 ['0.051'] | |
-bash-4.2$ python2.7 ./dnstest.py | |
Collecting data: . . . . . . . . . . . . | |
Securly 0.200 ['0.239', '0.161'] | |
Comodo Secure DNS 0.657 ['1.025', '0.289'] | |
SmartViper 1.043 ['1.058', '1.028'] | |
Verizon 0.104 ['0.040', '0.031', '0.449', '0.031', '0.036', '0.037'] | |
OpenDNS 0.022 ['0.022', '0.021'] | |
Level3 0.037 ['0.036', '0.037'] | |
Google 0.152 ['0.269', '0.036'] | |
OpenNIC 0.573 ['0.050', '1.096'] | |
Norton ConnectSafe 0.191 ['0.038', '0.344'] | |
Norton 0.122 ['0.043', '0.201'] | |
DNS Advantage 0.376 ['0.723', '0.029'] | |
local 0.025 ['0.025'] | |
# From Comcast. | |
fred:src$ python ./dnstest.py | |
Collecting data: . . . . . . . . . . . . | |
Securly 0.537 ['0.537'] | |
Comodo Secure DNS 0.509 ['0.475', '0.543'] | |
SmartViper 1.329 ['1.355', '1.304'] | |
Verizon 0.440 ['0.359', '0.893', '0.334', '0.366', '0.342', '0.347'] | |
OpenDNS 0.355 ['0.349', '0.360'] | |
Level3 0.339 ['0.343', '0.334'] | |
Google 0.365 ['0.506', '0.224'] | |
OpenNIC 0.783 ['0.291', '1.276'] | |
Norton ConnectSafe 0.301 ['0.228', '0.374'] | |
Norton 0.295 ['0.231', '0.358'] | |
DNS Advantage 0.307 ['0.363', '0.252'] | |
local 0.134 ['0.134'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Having some problems find the DNS package you used. Can you like me to the source?