Dnsdig - A script to test common DNS resolvers

There were some occasions to post this in a few threads.
So now I put it in a place.
Feel free to recommend DNS providers I should add (or remove).
Or anything else I suppose.

Example run

$ dnsdig

 Test common resolvers by calculating average response times of 3 queries.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------                                   
DNS               Primary          Secondary
                                   
AdGuard           94.140.14.14     94.140.15.15
CleanBrowsing     185.228.168.9    185.228.169.9
Cloudflare        1.1.1.1          1.0.0.1
Comodo            8.26.56.26       8.20.247.20
Control-D         76.76.2.2        76.76.10.2
dns0.eu           193.110.81.0     185.253.5.0
DNSFilter         103.247.36.36    103.247.37.37
Dyn/Oracle        216.146.35.35    216.146.36.36
FlashStart        185.236.104.104  185.236.105.105
Gcore             95.85.95.85      2.56.220.2
Google            8.8.8.8          8.8.4.4
Level3/Lumen      209.244.0.3      209.244.0.4
NextDNS           45.90.28.105     45.90.30.105
OpenDNS/Cisco     208.67.222.222   208.67.220.220
Quad9             9.9.9.9          149.112.112.112
SafeDNS           195.46.39.39     195.46.39.40
UltraDNS/Vercara  64.6.64.6        64.6.65.6
                                   
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 Do you wish to flush the DNS cache (y/N)? y

Current DNS 127.0.0.53
Avg time:  3.33333 ms

FlashStart 185.236.104.104
Avg time:  8.66667 ms

Cloudflare 1.1.1.1
Avg time:  17.6667 ms

SafeDNS 195.46.39.39
Avg time:  18.3333 ms

Control-D 76.76.2.2
Avg time:  28.3333 ms

Quad9 9.9.9.9
Avg time:  28.3333 ms

DNSFilter 103.247.36.36
Avg time:  29.3333 ms

NextDNS 45.90.28.105
Avg time:  29.3333 ms

Level3/Lumen 209.244.0.3
Avg time:  30 ms

UltraDNS/Vercara 64.6.64.6
Avg time:  36 ms

AdGuard 94.140.14.14
Avg time:  47 ms

OpenDNS/Cisco 208.67.222.222
Avg time:  50.6667 ms

Google 8.8.8.8
Avg time:  56 ms

Comodo 8.26.56.26
Avg time:  79.3333 ms

CleanBrowsing 185.228.168.9
Avg time:  94.3333 ms

Gcore 95.85.95.85
Avg time:  103.333 ms

dns0.eu 193.110.81.0
Avg time:  212 ms

Dyn/Oracle 216.146.35.35
Avg time:  241.667 ms

:information_source: Note :information_source:

As with many of my scripts .. this can be run remotely, with no need to download, as well:

bash <(curl -s https://gitlab.com/cscs/dnsdig/-/raw/main/dnsdig)
8 Likes

Nice script.

Based on something similar I had on a small PiHole device for some time, I would suggest the following:

  • Make it easy to also test a custom entry (your provider’s DNS)
  • Have an option to sort the results by time, so it’s easy to see which one is the fastest

Maybe make the query number a bit higher, or free choice. 3 is too little to detect hiccups, I think I had 10.

Thanks.

Usage: dnsdig

Options:
  -h, --help     Display this help message

Environment Variables:
  DOMAIN         Set the lookup domain
  SKIP           Skip the regular tests and header
  TESTDNS        Custom DNS server to test

https://gitlab.com/cscs/dnsdig/-/blob/main/dnsdig?ref_type=heads#L14

They should already be sorted by time by default.
(Except the current one which will be displayed at the top.)

Hm. It could certainly be increased. :thinking:

From my region the following are the top 14 fastest DNS server. It is funny that Google DNS and Oracle DNS did not make the cut. But OpenDNS and FlashStart did.

Not surprised that Cloudflare is there in the top 5. It is one of the most fastest DNS out there.

Firefox uses NextDNS, which is at the bottom, for Increased protection, i.e. secure DNS. Maybe it does make sense to shift to cloudflare DNS for using Secure DNS.

OpenDNS/Cisco 208.67.222.222
Avg time:  14 ms

DNSFilter 103.247.36.36
Avg time:  15 ms

FlashStart 185.236.104.104
Avg time:  17.3333 ms

Cloudflare 1.1.1.1
Avg time:  20 ms

Quad9 9.9.9.9
Avg time:  25 ms

SafeDNS 195.46.39.39
Avg time:  28.6667 ms

Comodo 8.26.56.26
Avg time:  43 ms

CleanBrowsing 185.228.168.9
Avg time:  44 ms

UltraDNS/Vercara 64.6.64.6
Avg time:  44 ms

AdGuard 94.140.14.14
Avg time:  47.3333 ms

Level3/Lumen 209.244.0.3
Avg time:  51.6667 ms

NextDNS 45.90.28.105
Avg time:  86.3333 ms

Sure, mine were - Cloudfare at the top my current as well as the fastest item… it was nice to see a comparison and tickle my narcissistic tendencies :joy:

Current DNS 1.1.1.1
Avg time:  3 ms

Cloudflare 1.1.1.1
Avg time:  2.66667 ms

Quad9 9.9.9.9
Avg time:  3.66667 ms

Google 8.8.8.8
Avg time:  23.6667 ms

FlashStart 185.236.104.104
Avg time:  25.3333 ms

OpenDNS/Cisco 208.67.222.222
Avg time:  26 ms

AdGuard 94.140.14.14
Avg time:  26.3333 ms

Level3/Lumen 209.244.0.3
Avg time:  26.3333 ms

CleanBrowsing 185.228.168.9
Avg time:  26.6667 ms

Control-D 76.76.2.2
Avg time:  26.6667 ms

Comodo 8.26.56.26
Avg time:  27 ms

NextDNS 45.90.28.105
Avg time:  27 ms

DNSFilter 103.247.36.36
Avg time:  27.3333 ms

Gcore 95.85.95.85
Avg time:  98.6667 ms

SafeDNS 195.46.39.39
Avg time:  160 ms

UltraDNS/Vercara 64.6.64.6
Avg time:  201.667 ms

dns0.eu 193.110.81.0
Avg time:  209.333 ms

Dyn/Oracle 216.146.35.35
Avg time:  386 ms

Interestingly Cloudfare is faster than my current DNS in this run :rofl:

Nice script. Glad none of them is faster than my own local unbound instance.

I have one entry with errors which throws a wrench in the sort:

Current DNS 127.0.0.53
Avg time:  0.666667 ms

UltraDNS/Vercara 64.6.64.6
Avg time:  21 ms

Comodo 8.26.56.26
Avg time:  22 ms

Level3/Lumen 209.244.0.3
Avg time:  22 ms

Cloudflare 1.1.1.1
Avg time:  23 ms

CleanBrowsing 185.228.168.9
Avg time:  24 ms

Google 8.8.8.8
Avg time:  40 ms

Quad9 9.9.9.9
Avg time:  51 ms

dns0.eu 193.110.81.0
Query errors
Avg time:  108.333 ms

AdGuard 94.140.14.14
Avg time:  21.6667 ms

Control-D 76.76.2.2
Avg time:  22.3333 ms

SafeDNS 195.46.39.39
Avg time:  25.6667 ms

OpenDNS/Cisco 208.67.222.222
Avg time:  27.6667 ms

Gcore 95.85.95.85
Avg time:  28.3333 ms

DNSFilter 103.247.36.36
Avg time:  29.6667 ms

Dyn/Oracle 216.146.35.35
Avg time:  30.6667 ms

FlashStart 185.236.104.104
Avg time:  41.3333 ms

NextDNS 45.90.28.105
Avg time:  68.3333 ms

Good to see that a local dns is already in there. I ran it from the git repo via curl, so I missed that.