19

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

27

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 to cat /run/systemd/resolve/resolv.conf to see the resolv.conf file generated by systemd-resolved.

7
  • 2
    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
  • @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
    Aug 18, 2022 at 2:39
  • 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. Aug 19, 2022 at 10:02
  • 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. Aug 19, 2022 at 10:04
  • systemd-resolv got self-awareness, it just doing things, not care what you want
    – yurenchen
    Nov 27, 2022 at 5:03
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .