15

I know that systemd-resolve --status lists all my connections and their DNS servers and nmcli connection show <connection> | grep -i dns will list the priority of the DNS connections. But is there a single command I can run that will list all DNS servers and their priority/order?

2 Answers 2

19

It is stupid, but you can't!

systemd-resolved follows internal rules to choose the "correct" DNS. This might be different for each query. It uses things like if a server worked or failed in the past, interface order and even what domains allocated to each interface. It's difficult to manage with some VPN setups.

The best you can do is check the /run/systemd/resolve/resolv.conf file. That is the resolv.conf file generated by systemd-resolved.

5
  • 1
    I also gave up and install dnsmasq with rules to resolve some domains in certain servers (ie: internal DNS to the internal network dns server). This solved my problems using several VPNs and dns resolve order
    – higuita
    Jan 30, 2020 at 20:48
  • Why o why am I not surprised that linux developers, who after 20 years still can't make a properly functional desktop that isn't littered with bugs and inconsistencies, can't make a properly functional command line interface also. It's so depressing. Open Sores indeed. Aug 15 at 20:38
  • @ChristopherThomas notice that all OS have weak and strong points, having used both windows and macosX, i can tell you that they both have lot of stupid "features" in the DNS. I understand that systemd was developed for the clueless user and it tries to guess things... but still, not all users are clueless and having only that operating node is stupid.The problem is that there is no "one size fits all" and that is why all OS have major issues with managing DNS. That being said, while not perfect, IMHO, linux is still a much better OS and desktop than the other two, and it's free and open
    – higuita
    2 days ago
  • systemd's command line interface is absolute garbage. It lacks many features that would be useful for people building interfaces to automate and control a linux system through user interfaces, etc. But it just doesn't have them. They only implemented the basic functionalities and missed a lot of what actual system administrators need. We don't want to parse weird and wacky command line outputs using sed or grep for some value. I expect to be able to query the value and get it directly. It's absolute garbage. Even knowledgable administrators suffer to get useful information out of it. 19 hours ago
  • and by the way, mac does not have problems managing DNS and has had a consistent command line interface for years already and it's stable and reliable. So your claim that all OS have this issue is false. Windows also has a stable way to interact with it's networking system through the command line. Linux is the only one out of those three with problems. 19 hours ago
0

It is possible to make a dns priority with

nmcli -p connection modify MY_VPN_CONNECTION ipv4.dns-priority -42

as taken from https://github.com/systemd/systemd/issues/6076

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.