32

I am using google open DNS. How can I measure the speed of a DNS server?

8 Answers 8

30

If you just want to time the lookup of a single record, use time dig a foobar.com @8.8.8.8. This testing method really isn't that good since after the first lookup, you'll be getting cached results and whatever server is closer to you will give you the fastest response.

namebench is probably the tool you're looking for. It does lookups based on domains are in your browser cache, random records from a list of popular records, etc. It is highly configurable to test your preferred list of DNS servers, your list of records, etc.

2
  • 2
    With DNS over HTTPS/TLS (DoH) time dig +tls a stackexchange.com @1.1.1.1 Aug 22, 2022 at 15:38
  • Note: For Ubuntu, dig support for +tls option started with 22.04 LTS Mar 23 at 18:34
19

You Can use the folllowing command:

  dig YOURDOMAIN +nssearch 
1
  • 2
    +[no]nssearch When this option is set, dig attempts to find the authoritative name servers for the zone containing the name being looked up and display the SOA record that each name server has for the zone.
    – Adriano P
    Oct 31, 2018 at 16:55
7

This helped me on the bash prompt. I had an issue where the name servers were randomly timing out. You need the dig utility, which is not a default on minimal installs. You can get it by installing

$ yum install bind-utils

for Fedora/RedHat/CentOS or

$ apt install dnsutils

for Ubuntu/Debian

$ while true; do dig www.google.com | grep time; sleep 2; done

This yields an output like:

;; Query time: 2 msec
;; Query time: 1 msec
;; connection timed out; no servers could be reached
;; Query time: 1 msec
;; Query time: 53 msec
;; connection timed out; no servers could be reached
;; connection timed out; no servers could be reached
;; Query time: 2 msec
;; Query time: 5 msec
;; Query time: 3 msec

On a healthy connection, it should be no more than 2 msec a query.

6

Using namebench

Debian/Ubuntu

sudo apt-get install namebench

MacOS

brew install namebench

Example output

namebench 
...
> Sending 1 queries to 7 servers... [0/7]
> Sending 1 queries to 7 servers... [4/7]
> Sending 1 queries to 7 servers... [6/7]
> Sending 1 queries to 7 servers... [7/7]
> Saving report to /tmp/namebench_2019-08-13_1148.html
> Saving detailed results to /tmp/namebench_2019-08-13_1148.csv
> Opening /tmp/namebench_2019-08-13_1148.html
> Complete! SYS-127.0.0.53 [127.0.0.53] is the best.
Au revoir, mes amis!

Namebench will make an html report with the results of the best DNS for you based on response speed of the DNS server.

1
5

1. dnsperf

dnsperf and resperf are free tools developed by Nominum/Akamai (2006-2018) and DNS-OARC (since 2019) that make it simple to gather accurate latency and throughput metrics for Domain Name Service (DNS). These tools are easy-to-use and simulate typical Internet, so network operators can benchmark their naming and addressing infrastructure and plan for upgrades. The latest version of the dnsperf and resperf can be used with test files that include IPv6 queries.

Building from Git repository

git clone https://github.com/DNS-OARC/dnsperf.git
cd dnsperf
./autogen.sh
./configure [options]
make
make install

NOTE

The binary file will be complied in ./srt directory

simple config file

and the name of it is data

shakiba.net A

run the test

-d data is for config file (see above)

./src/dnsperf -s 1.1.1.1 -d data -c 10 -l 10 -Q 100

and this means

  • -s source IP address == DNS server to query from
  • -d read record from this file
  • -c number of clients
  • -l for this duration of time (10 seconds)
  • -Q send this number of query

here 10 clients + 100 queries => 1000 requests

sample output

Statistics:

  Queries sent:         1000
  Queries completed:    1000 (100.00%)
  Queries lost:         0 (0.00%)

  Response codes:       NOERROR 1000 (100.00%)
  Average packet size:  request 34, response 87
  Run time (s):         10.075874
  Queries per second:   99.246974

  Average Latency (s):  0.083850 (min 0.080296, max 0.091041)
  Latency StdDev (s):   0.001694

2. dnsdiag

DNS Measurement, Troubleshooting and Security Auditing Toolset

Ever been wondering if your ISP is hijacking your DNS traffic? 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 to perform basic audits on your DNS requests and responses to make sure your DNS is working as you expect.

use via Docker

docker run -it --rm farrokhi/dnsdiag /bin/bash

sample command

 ./dnseval.py -t A -f public-servers.txt -c10 shakiba.net  

which means

  • -t type of query e.g. A
  • -f read config file
  • -c number of query

config file

the file public-servers.txt contains list of DNS server to query from e.g.

#Cloudflare
1.0.0.1
1.1.1.1

sample test + output

./dnseval.py -t A -f public-servers.txt -c10 shakiba.net
server      avg(ms)     min(ms)     max(ms)     stddev(ms)  lost(%)  ttl        flags                  response
---------------------------------------------------------------------------------------------------------------
1.0.0.1     7.301       6.502       11.736      1.566       %0       298        QR -- -- RD RA -- --   NOERROR             
1.1.1.1     6.816       6.195       8.433       0.622       %0       297        QR -- -- RD RA -- --   NOERROR 
4

You can use this bash script:

#/bin/bash

DOMAIN=wikipedia.org;
echo "Tests common resolvers and calculates average response times by testing each resolver 3 times."
echo "************************"
echo "cPanel: 94.237.127.9"
echo "Cloudflare: 1.1.1.1"
echo "Level 3: 4.2.2.2"
echo "OpenDNS: 208.67.220.220"
echo "Google: 8.8.8.8"
echo "ANTEL: 200.40.30.245"
echo "Dyn: 216.146.35.35"
echo "Neustar: 156.154.70.1"
echo "puntCAT: 109.69.8.51"
echo "UncensoredDNS: 91.239.100.100"
echo "Hurricane Electric: 74.82.42.42"
echo "************************"
echo
for resolver in 94.237.127.9 1.1.1.1 4.2.2.2 208.67.220.220 8.8.8.8 200.40.30.245 216.146.35.35 156.154.71.1 109.69.8.51 91.239.100.100 74.82.42.42
do
   echo $resolver
   for reps in {1..3}
   do
    dig $DOMAIN @$resolver | awk '/time/ {print $4 " ms"}'
    sleep 3
   done |awk '/ms/ {sum+=$1} END {print "Avg time: ",sum/3, " ms"}'
   echo
done

Of course you can change the testing domain (in the example is wikipedia.org) and the DNS servers.

It returned this, in a test run:

94.237.127.9
Avg time:  14.3333  ms

1.1.1.1
Avg time:  2  ms

4.2.2.2
Avg time:  0.333333  ms

208.67.220.220
Avg time:  65.6667  ms

8.8.8.8
Avg time:  10  ms

200.40.30.245
Avg time:  0  ms

216.146.35.35
Avg time:  46  ms

156.154.71.1
Avg time:  5  ms

109.69.8.51
Avg time:  0  ms

91.239.100.100
Avg time:  210  ms

74.82.42.42
Avg time:  2.66667  ms
3

Several of the above answers mention namebench. Despite being a useful tool, it is currently unmaintained. It's successor is naminator, and unlike namebench, it is currently under active development. You may want to check it out.

2
  • This is no longer actively maintained, and the releases are broken. Aug 18, 2021 at 9:40
  • The last commit on the repository is from 2 days ago at the time of writing. What do you mean by "actively maintained"?
    – Stunts
    Oct 1, 2021 at 15:35
0

To make sure that you will audit possible DNS lookup delays that can happen when your apps try to access the database (with a possibly non-fixed ip), you can run this infinite script that monitors dns resolution every 5 seconds and appends the results to a file.

while :; do { echo -n "$(date --rfc-3339='seconds') "; { time dig a db-host > dev/null ; } 2>&1 | grep real ; sleep 5 ; } >> /tmp/dns-latency ; done

Output in the file:

2021-12-08 14:31:25+02:00 real 0m0,002s
2021-12-08 14:31:30+02:00 real 0m0,002s
2021-12-08 14:31:35+02:00 real 0m0,002s
2021-12-08 14:31:40+02:00 real 0m0,002s
2021-12-08 14:31:45+02:00 real 0m0,002s
2021-12-08 14:31:50+02:00 real 0m0,003s

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .