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 +search uses your search domains, which dig skips by default

Dig
~/tips/tip-dig-search-ndots

dig +search nas

Make dig resolve a short host name the way your system does, through the search list.

ping nas works but dig nas says NXDOMAIN. That is not a DNS problem: dig ignores the search domains in /etc/resolv.conf unless you tell it otherwise.

Add +search, and +showsearch if you want to see each attempt:

dig +search nas
dig +showsearch nas

With a search home.example line in resolv.conf, dig now tries nas.home.example and returns that answer. +showsearch prints every name it tried along the way, which shows the order in which the domains are tried.

I think this is the most common reason people distrust dig on a LAN. The ndots setting decides when the search list kicks in. A name with fewer dots than ndots (1 by default) gets the search domains appended first. You can override it for one query with +ndots=2. Kubernetes pods use ndots:5, which is why a lookup of api.example.com inside a pod first tries several cluster domains; that is a nice thing to see with +showsearch.

dig reads /etc/resolv.conf itself. On systems with systemd-resolved that file may point at the stub resolver, and per link search domains live in resolved, so resolvectl query nas can still give a different answer than dig. On macOS dig also misses domains set per network service; scutil --dns shows those.

Further reading: dig manual (BIND 9), resolv.conf(5) man 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 @8.8.8.8 www.google.com +subnet=203.0.113.0/24 dig +yaml example.com A dig +short +identify example.com @9.9.9.9 All Dig tips (36) All topics

Link