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: resolvectl query shows how a name was resolved

Linux
~/tips/tip-dns-resolvectl-query

resolvectl query example.com

Resolves a name through systemd-resolved and shows which link, protocol and cache gave the answer.

On a modern Linux box, dig and your applications may not use the same path. dig talks to a server directly. Your apps go through systemd-resolved.

resolvectl query asks the local resolver, the same way a program would, and prints which interface and protocol the answer came from and whether it was served from cache.

resolvectl query example.com

The cache note matters. If dig finds a name but a program cannot, run this one. It also resolves names that dig never sees, like single-label names that expand through search domains or names answered by mDNS on the local network. Add --type=MX for another record type.

One caveat: with --type= it switches to a lower level lookup and stops applying search domains. And this only helps on systems that run systemd-resolved, which is the default on current Ubuntu but not everywhere.

For the full picture of which DNS servers a link uses, resolvectl status is the companion. Query tells you what happened to one name, status tells you how the resolver is set up.

Further reading: resolvectl manual, On this site: resolvectl flush-caches clears the DNS cache on Linux, On this site: resolvectl monitor streams every DNS query live

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link