DNSDiag – DNS Diagnostics And Performance Measurement Tools

Ever been wondering if your ISP is hijacking your DNS traffic ^(https://decentralize.today/is-your-isp-hijacking-your-dns-traffic-f3eb7ccb0ee7#.fevks5wyc)? Ever observed any misbehavior with your DNS responses? Ever been redirected to wrong address and suspected something is wrong with your DNS? Here we have a set of tools ^(http://github.com/farrokhi/dnsdiag) to perform basic audits on your DNS requests and responses to make sure your DNS is working as you expect.
You can measure the response time of any given DNS server for arbitrary requests using dnsping. Just like traditional ping utility, it gives you similar functionality for DNS requests.
You can also trace the path your DNS request takes to destination to make sure it is not being redirected or hijacked. This can be done by comparing different DNS queries being sent to the same DNS server using dnstraceroute and observe if there is any difference between the path.
dnseval evaluates multiple DNS resolvers and helps you choose the best DNS server for your network. While it is highly recommended to use your own DNS resolver and never trust any third-party DNS server, but in case you need to choose the best DNS forwarder for your network, dnseval lets you compare different DNS servers from performance (latency) and reliability (loss) point of view.

dnspython ^(http://www.dnspython.org/) and cymruwhois ^(https://pythonhosted.org/cymruwhois/).

There are several ways that you can use this toolset. However using the sourcecode is always recommended.

From Source Code

  1. You can checkout this git repo and its submodules
git clone https://github.com/farrokhi/dnsdiag.git
cd dnsdiag
pip3 install -r requirements.txt
  1. You can alternatively install the package using pip:
pip3 install dnsdiag

From Binary
From time to time, binary ^(http://www.kitploit.com/search/label/Binary) version will be released for Windows, Mac OS X ^(http://www.kitploit.com/search/label/Mac%20OS%20X) and Linux ^(http://www.kitploit.com/search/label/Linux) platforms. You can grab the latest release from releases page ^(https://github.com/farrokhi/dnsdiag/releases).

dnsping pings a DNS resolver ^(http://www.kitploit.com/search/label/Resolver) by sending an arbitrary DNS query for given number of times:

% ./dnsping.py -c 3 -t AAAA -s dnsdiag.org
dnsping.py DNS:, hostname: dnsdiag.org, rdatatype: AAAA
4 bytes from seq=0 time=123.509 ms
4 bytes from seq=1 time=115.726 ms
4 bytes from seq=2 time=117.351 ms

--- dnsping statistics ---
3 requests transmitted, 3 responses received, 0% lost
min=115.726 ms, avg=118.862 ms, max=123.509 ms, stddev=4.105 ms

This script calculates minimum, maximum and average response time as well as jitter (stddev)

dnstraceroute is a traceroute ^(http://www.kitploit.com/search/label/Traceroute) utility to figure out the path that your DNS request is passing through to get to its destination. You may want to compare it to your actual network traceroute and make sure your DNS traffic is not routed to any unwanted path.

% ./dnstraceroute.py --expert -C -t A -s facebook.com
dnstraceroute.py DNS:, hostname: facebook.com, rdatatype: A
1 ( 1 ms
2 ( 4 ms
3 ( 693 ms
4 ( 3 ms
5 google ^( https://9to5google.com)-public-dns-b.google.com ( 8 ms

=== Expert Hints ===
[*] public DNS server is next to a private IP address (possible hijacking)

Using --expert will instruct dnstraceroute to print expert hints (such as warnings of possible DNS traffic hijacking).

dnseval is a bulk ping utility that sends an arbitrary DNS query to a give list of DNS servers. This script is meant for comparing response time of multiple DNS servers at once:

% ./dnseval.py -t AAAA -f public-servers.txt -c10 yahoo.com
server avg(ms) min(ms) max(ms) stddev(ms) lost(%) ttl flags
------------------------------------------------------------------------------------------------------ 270.791 215.599 307.498 40.630 %0 298 QR -- -- RD RA -- -- 222.955 171.753 307.251 60.481 %10 291 QR -- -- RD RA -- --
ns.ripe.net 174.855 160.949 187.458 10.099 %0 289 QR -- -- RD RA -- -- 172.798 163.892 189.918 7.823 %0 287 QR -- -- RD RA -- -- 178.594 169.158 184.696 5.067 %0 285 QR -- -- RD RA -- -- 153.574 138.509 173.439 12.015 %0 284 QR -- -- RD RA -- -- 153.182 141.023 162.323 6.700 %0 282 QR -- -- RD RA -- -- 154.840 141.557 163.889 7.195 %0 281 QR -- -- RD RA -- -- 156.270 147.320 161.365 3.958 %0 279 QR -- -- RD RA -- -- 159.329 151.283 163.726 3.958 %0 278 QR -- -- RD RA -- -- 171.098 163.612 181.147 5.067 %0 276 QR -- -- RD RA -- -- 175.335 160.920 185.618 8.726 %0 274 QR -- -- RD RA -- --

Babak Farrokhi

  • twitter: @farrokhi
  • github: github.com/farrokhi ^(https://github.com/farrokhi/)
  • website: farrokhi.net ^(https://farrokhi.net/)

Download Dnsdiag ^(https://github.com/farrokhi/dnsdiag)

Author: Marshmallow

Marshmallow Android is BT Ireland’s Head of Sales for Republic of Ireland domestic multi-site companies, indigenous MNCs and public sector accounts. He is responsible for the direction and control of all sales activity in the region. He has over 10 years management experience from high growth start-ups to more established businesses. He’s led teams in Ireland, India and China across various industries (ICT, On-Line Recruitment, Corporate Training and International Education).