brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: dig +short +identify adds which server gave each answer

Dig
~/tips/tip-dig-identify-short

dig +short +identify example.com @9.9.9.9

Keep the short output but see the server address and response time on every line.

+short is great for a quick answer, but it drops the line that tells you which server replied. +identify puts that back on each line.

dig +short +identify example.com @9.9.9.9
dig +short +identify example.com @1.1.1.1

The output looks like 172.66.147.243 from server 9.9.9.9 in 10 ms., one line per record. You still get the compact answer, plus the server address and the time it took.

I find it handy for comparing resolvers side by side, and for scripts that log lookups. If you query several servers in a loop, the log shows which server gave which answer, and a slow one stands out right away.

for s in 9.9.9.9 1.1.1.1 192.0.2.53; do dig +short +identify example.com @"$s"; done

The extra text only appears together with +short; in the normal output the server is already in the SERVER: line at the bottom. It is also handy to know that when a server does not answer at all, there is no line to identify, just a timeout message. A query that returns no records prints nothing, so an empty result can mean NODATA or NXDOMAIN; drop +short to see the status.

Further reading: dig manual (BIND 9)

Going deeper: Guide: dig for beginners, look up DNS records and read the answer

More Dig tips dig +noall +answer DS example.com dig nope.iana.org @9.9.9.9 | grep -E 'status|SOA' dig +search nas dig @8.8.8.8 www.google.com +subnet=203.0.113.0/24 dig +yaml example.com A All Dig tips (36) All topics

Link