49

How would you go about finding the DNS servers used by systemd-resolved, for troubleshooting purposes?

Generally I can use dig and test the DNS servers shown in /etc/resolv.conf. (Or windows - ipconfig /all + nslookup). But that approach doesn't work when resolv.conf just points to a local resolver daemon on a loopback address. What method is used under systemd-resolved, to show the DNS servers it uses?


(unbound has config files I could look into. dnsmasq does too, though I'm not sure if servers can be added dynamically without a config file. Even NetworkManager, now has nmcli, and I see you can query nmcli d show wlan0 to show the DNS configuration for an interface.)

35

Use resolvectl status (systemd-resolve --status when using systemd version earlier than 239) to show your global and per-link DNS settings.

  • Unfortunately, in my ubuntu 16.04.6 there is no resolvectl and the systemd-resolve command has no "--status" option. – Marnix A. van Ammers Aug 12 at 2:24
31

Very helpful for troubleshooting is also:

journalctl -u systemd-resolved -f

There you can see what systemd-resolved is really doing. In my case it was not contacting the DNS servers that were reported via systemd-resolve --status at all. If it's doing weird things like that, then somtimes a restart via sudo systemctl restart systemd-resolved is a good idea.

EDIT: In order to get more information from resolved you need to put

[Service]
Environment=SYSTEMD_LOG_LEVEL=debug

into the override.conf of systemd-resolved via

sudo systemctl edit systemd-resolved
  • 3
    It might be worth noting that after running sudo systemctl edit systemd-resolved it seems sudo systemctl restart systemd-resolved needs to be run in order for the new settings to be applied. Thanks! – bmaupin Apr 23 at 15:13
  • After all these years without having to deal with windows, not much anyway, you get the "If it's doing weird things like that, then somtimes a restart via.." advice and you know you are back to where you started. Sigh. – Jaap Versteegh Aug 22 at 10:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.