DNS resolution speed directly impacts web browsing latency, API response times, and server communication performance. When web pages load sluggishly or connections stall before data transfers begin, an unresponsive or poorly routed Domain Name System (DNS) resolver is often the underlying culprit. In Ubuntu, the dig (Domain Information Groper) command line utility provides precise diagnostics for DNS lookups, detailing the exact response time in milliseconds for every queried nameserver.
Installing the dig Utility in Ubuntu
The dig command is distributed as part of the bind9-dnsutils package. While installed by default on Ubuntu Desktop, minimal or cloud server installations may require installing it manually.
# Update package repositories and install dnsutils
sudo apt update
sudo apt install bind9-dnsutils -y
Running a Basic Query and Reading Query Time
To measure the resolution time for a domain using your system’s default configured DNS resolver, run dig followed by the hostname:
dig example.com
In the terminal output, scroll down to the final footer statistics block. Locate the following lines:
;; Query time: 24 msec
;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP)
;; WHEN: Mon Oct 26 21:50:00 UTC 2026
;; MSG SIZE rcvd: 56
The Query time field reflects the round-trip latency in milliseconds (msec). In standard local setups, SERVER: 127.0.0.53 represents Ubuntu’s native systemd-resolved stub listener.
Comparing Speeds Between Alternative DNS Resolvers
To determine whether alternative public nameservers—such as Cloudflare (1.1.1.1) or Google Public DNS (8.8.8.8)—deliver faster resolution than your ISP’s default resolver, query them directly using the @ prefix:
# Test Cloudflare DNS resolution speed
dig @1.1.1.1 example.com | grep "Query time"
# Test Google Public DNS resolution speed
dig @8.8.8.8 example.com | grep "Query time"
# Test Quad9 DNS resolution speed
dig @9.9.9.9 example.com | grep "Query time"
Running each command multiple times allows you to evaluate both initial un-cached resolution speed and subsequent cached response latency.
Bypassing Cache to Measure Raw Authoritative Lookup Latency
By default, intermediate resolvers cache DNS records according to their TTL (Time to Live). If you need to test true un-cached authoritative lookup speeds, query the root or authoritative nameservers directly with the +trace argument:
dig example.com +trace
The +trace flag executes an iterative traversal from root nameservers down to the authoritative zone, revealing the resolution time at each step of the DNS hierarchy.