A DNS ping tester measures two different things: the network round trip to a DNS server (ping 8.8.8.8) and the time the server takes to answer a real lookup. The second number is the one that matters, and you can read it on Windows with Measure-Command { Resolve-DnsName example.com -Server 8.8.8.8 -DnsOnly } or on macOS and Linux with dig @8.8.8.8 example.com.
Replace 8.8.8.8 with the resolver you want to test and example.com with any domain. All sample output below is example output, not a measurement of any real network.
Ping vs a real DNS query: which one tests DNS?
ping sends Internet Control Message Protocol (ICMP) echo requests and shows round-trip times. Microsoft's documentation describes it as verifying IP-level connectivity. It tells you how far away the server is on the network. It does not exercise the DNS service at all, because DNS queries are a different protocol.
That has two consequences:
- A server can answer DNS quickly and still ignore ping. A "Request timed out" reply from
pingis not proof that the resolver is down. - A server can answer ping in a few milliseconds and still be slow at DNS, for example when it has to ask other servers for a name it has not cached.
Use ping for the path, and a real query for the service. The rest of this article does both.
How to ping a DNS server
On Windows, send 10 echo requests instead of the default 4:
ping -n 10 8.8.8.8
Example output (last lines):
Packets: Sent = 10, Received = 10, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 11ms, Maximum = 19ms, Average = 13ms
On Windows, /n sets the number of requests (default 4) and /w sets how long to wait for each reply in milliseconds (default 4000). On macOS and Linux the count flag is -c, so the equivalent is ping -c 10 8.8.8.8.
Look at two numbers: the average round trip, and the packet loss. Loss above 0% on a wired connection points at the link, not at DNS.
How to time a DNS lookup on Windows
The Resolve-DnsName cmdlet does the lookup, and its -Server parameter sends the query to a specific DNS server instead of the ones configured on your adapter. -DnsOnly restricts the query to the DNS protocol, so LLMNR and NetBIOS are not tried. Wrap it in Measure-Command to get the elapsed time:
Measure-Command { Resolve-DnsName -Name example.com -Server 8.8.8.8 -Type A -DnsOnly } | Select-Object TotalMilliseconds
Example output:
TotalMilliseconds
-----------------
22.4137
The time includes starting the cmdlet, so it is slightly higher than the pure network time. That overhead is the same for every server you test, which is why comparisons stay fair.
Compare several DNS servers at once
Run this in PowerShell. It queries each server for the same three names and prints the average time. The addresses are the primary IPv4 addresses of Google, Cloudflare, Quad9 and OpenDNS, listed in public DNS servers compared. Add your router or ISP resolver to the list to include it.
$servers = '8.8.8.8', '1.1.1.1', '9.9.9.9', '208.67.222.222'
$names = 'example.com', 'wikipedia.org', 'microsoft.com'
foreach ($server in $servers) {
$timesMs = foreach ($name in $names) {
(Measure-Command {
Resolve-DnsName -Name $name -Server $server -Type A -DnsOnly -ErrorAction Stop
}).TotalMilliseconds
}
[pscustomobject]@{
Server = $server
AverageMs = [math]::Round(($timesMs | Measure-Object -Average).Average, 1)
}
}
Example output:
Server AverageMs
------ ---------
8.8.8.8 21.3
1.1.1.1 14.8
9.9.9.9 26.0
208.67.222.222 19.5
Those numbers are made up to show the layout. Your results will differ, and the order will differ too. If a server does not answer, -ErrorAction Stop makes the loop stop with the error instead of printing a misleading time. Wrap the call in try/catch if you want the loop to continue past failures.
How to test DNS speed on macOS and Linux with dig
dig prints the query time with every answer. The @ sign picks the server:
dig @1.1.1.1 example.com
Look for the statistics comment at the end of the output. Example output:
;; Query time: 14 msec
;; SERVER: 1.1.1.1#53(1.1.1.1) (UDP)
By default dig prints times in milliseconds; the -u option switches the display to microseconds. To see only the time lines for several servers:
for server in 8.8.8.8 1.1.1.1 9.9.9.9 208.67.222.222; do
echo "$server"
dig @"$server" example.com +tries=1 +timeout=2 | grep "Query time"
done
+tries=1 makes dig send the query once instead of retrying (the default is 3 tries), and +timeout=2 gives up after 2 seconds (the default is 5). Without them, a dead server can hide behind a slow retry. If dig is missing, it comes in the dnsutils package on Debian and Ubuntu and bind-utils on Fedora and RHEL.
Why the first lookup is slower than the second
A recursive resolver keeps answers in a cache for as long as the record's time to live (TTL) allows. The first request for a name may force the resolver to ask other servers, and the next request is answered from memory. This is the main trap when comparing servers:
- A popular name such as
example.comis likely already cached by a big public resolver, so the test measures network distance, not resolution work. - A rarely requested name forces a full lookup the first time, so it shows the worst case.
Test a mix: a very popular name and a few less common ones, and run the whole set at least twice. Throw away the first pass if you only care about the typical case. If your own computer has a cached answer, that is a separate cache. To clear it before testing, see how to flush the DNS cache.
How to read the results
| What you see | What it usually means |
|---|---|
| Ping fast, lookup fast | Healthy server on a short path. |
| Ping fast, lookup slow on the first run, fast on the second | The server had to resolve the name itself, then cached it. Normal. |
| Ping times out, lookup works | The server ignores ICMP. The DNS service is fine. |
| Ping works, lookup times out | The path is fine, but the DNS service is unreachable or blocked. Port 53 may be filtered on your network. |
| Both vary widely between runs | An unstable link (Wi-Fi interference, congestion). Test on a wired connection to separate the two. |
Differences of a few milliseconds are rarely noticeable. A resolver that answers in 12 ms instead of 20 ms saves 8 ms on the first lookup of a name, and nothing on later ones. Switch only if the gap is large or one of your current servers is failing. Reliability, filtering and privacy policy are better reasons to choose a resolver than a small speed difference.
Apply the fastest server
If a public resolver clearly beats the one you use now, set it on your adapter or router. For the steps, see how to change the DNS server on Windows. Enter both addresses of the same service. After changing, run the test again, because your adapter may still use a cached answer from the old server.
If every server looks slow or fails
If all servers time out on lookups but ping works, something on your network is blocking DNS traffic, such as a firewall, a VPN client or a captive portal. If only your configured server fails and a public one answers, the problem is that server. Both cases are covered in DNS server not responding.
Frequently asked questions
- What is a good DNS response time?
- There is no official threshold, and the number depends on your connection and distance to the resolver. What matters is the comparison: run the same test against your current server and against alternatives, and keep the one that answers consistently faster. A resolver that answers from its cache will always look faster than one that has to ask other servers, so repeat each test several times.
- Why does ping to a DNS server show 'Request timed out'?
- ping sends ICMP echo requests, and a server is free to ignore them. A timeout does not prove the DNS service is down. Send a real DNS query to the same address with Resolve-DnsName or dig. If that returns an answer, the resolver is working and only ICMP is being dropped.
- Does a faster DNS server make my internet faster?
- Only for the lookup step. DNS turns a name into an address before a page starts to load, so a faster resolver can shorten that first step. It does not change your download speed, and repeated lookups of the same name are usually answered from a cache anyway.
- Is there a built-in DNS benchmark tool in Windows?
- Not as a single tool. Windows ships ping, nslookup and the Resolve-DnsName cmdlet, and you can time the lookups with Measure-Command. The script in this article does that for several servers at once.