Dnsmasq query time

I ran dig yahoo.com command on the router and my PC and the Query time was ~1ms for the router and 55..65ms for the laptop (on both wired & wireless connections). In all cases the SERVER was pointing at my router as the DNS server, the TTL was minutes or more, and the dnsmaq log confirmed that the entry is serviced from the cache. I tried several different domains with the same result or ~60ms response time for wired and wireless while dnsmasq is logging that they are cached.

I am using 18.06. Is it normal to have such seemingly long response time on the local network? My guess is that it is not, but then I am not sure what could be causing this delay.

The 55ms query might be the one that that Dnsmasq needed to consult the upstream forward resolver to get the records. The 1ms query is a cached response coming out of Dnsmasq itself.

There's also the likelihood that one of your configured upstream forward resolver experienced transient slowness. These can be easily confirmed by running tcpdump on your router while repeating your experiment.

Here's mine, cold lookup vs cached response:

$ (dig yahoo.com; dig yahoo.com) | grep "Query time"
;; Query time: 26 msec
;; Query time: 0 msec

As I mentioned in the post, the dnsmasq logs confirmed the domain was cached already and I still got a 55ms response time.
Did you run your test on Linux? Ubuntu has its own local dnsmasq running locally and that explains the 0ms response time, so this would not be a real test.

No I ran that off a Mac machine with dig confirming that the responses came from the router IP.

Another macOS user here:

$ (dig yahoo.com; dig yahoo.com) | grep "Query time"
;; Query time: 95 msec
;; Query time: 3 msec

$ sudo killall -HUP mDNSResponder

$ (dig yahoo.com; dig yahoo.com) | grep "Query time"
;; Query time: 3 msec
;; Query time: 1 msec

Consistent with @phuque99 results.

I think it's a problem with macOS's version of dig. Any DNS cache I try to query has some sort of delay, usually +50ms. I've installed ldns via homebrew as a workaround and just use drill instead of dig. So far I haven't seen any artificial delay.

1 Like

Hmm, so it could be an issue with my Mac or dig. I also tried a tablet and the query time was <10ms. Thx for sharing your results: I will have to troubleshoot my Mac now.

$ (dig yahoo.com; dig yahoo.com) | grep "Query time"
;; Query time: 57 msec
;; Query time: 60 msec
$ sudo killall -HUP mDNSResponder
$ (dig yahoo.com; dig yahoo.com) | grep "Query time"
;; Query time: 59 msec
;; Query time: 61 msec

Not saying that's what it is, but I'd check: https://9to5mac.com/2018/01/15/macos-dns-hijacking-malware/

Thx, but that is thankfully not it.