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 +timeout=2 +tries=1 gives up on a dead server quickly

Dig
~/tips/tip-dig-time-tries-fast-fail

dig +timeout=2 +tries=1 @10.0.0.53 example.com

Sets a short timeout and a single try so failures show up fast.

Querying a resolver that is down makes dig sit for a long time. The defaults are a five second timeout and three tries, so you wait around fifteen seconds for a failure.

dig +timeout=2 +tries=1 @10.0.0.53 example.com
dig +timeout=2 +tries=1 +short @10.0.0.54 example.com

+timeout sets the wait per attempt in seconds and +tries sets how many attempts dig makes. Lower values are handy in a loop or script that checks several resolvers in a row, because one dead server no longer holds up the rest. The exit status is 9 when no reply came back, so || in a shell script works well here.

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