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 takes several names and types on one command line

Dig
~/tips/tip-dig-multiple-queries

dig +noall +answer example.com A example.org MX example.net NS

Ask for A, MX, NS and other records of several names in a single dig call.

You do not need a loop or a file to ask dig a handful of questions. Put them one after the other on the command line.

dig +noall +answer example.com A example.org MX example.net NS

Each name with its type is a separate query, sent in order. With +noall +answer the result is one tidy block of records, for example the A records of example.com, then example.org. 300 IN MX 0 ., then the NS records of example.net.

I like this for a quick audit of a domain: web, mail and name servers in one command. It is easier to copy into a ticket than five separate outputs.

Options before the first name apply to every query, and options after a name apply only to that query. So dig +short example.com A example.org MX +noshort mixes styles, which can be confusing. I’d keep global options at the front to avoid surprises.

This also explains a common mistake. dig example.com www.example.com is not one query for two names but two queries, and an argument that is not a known type is taken as another name. For more than a handful of names, a file with -f stays easier to read.

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