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 -f reads a whole list of names from a file

Dig
~/tips/tip-dig-f-batch-file

dig -f names.txt +noall +answer

Runs many DNS lookups from one file in a single dig call.

When I need to check twenty hostnames, I do not want to type twenty commands. dig can read its queries from a file.

printf 'example.com A\nexample.org MX\nexample.net TXT\n' > names.txt
dig -f names.txt +noall +answer

With -f, dig reads one query per line, written the same way as on the command line, including a record type and options like @server. Combine it with +noall +answer to get a compact list. Empty lines and lines that start with # or ; are skipped, so you can keep notes in the file. Queries run one after another, so a long file against a slow resolver takes a while.

Further reading: dig manual page

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