I am experiencing an issue with DNS and to help narrow down the problem, I have been asked to configure my machine's DNS settings manually, only specifying one DNS server instead of the two returned via DHCP, so the server admins can find out whether my problem is only happening on one DNS server or both.

However I have been unable to configure systemd-resolved such that it will manually accept my DNS config.

I tried the following, all of which still sent DNS requests randomly between both servers, even after restarting both systemd-networkd and systemd-resolved:

  • Specifying DNS= in the [Resolve] section of /etc/systemd/resolved.conf
  • Specifying DNS= in the [Network] section of /etc/systemd/network/eth0.conf (the only file in this folder)
  • Editing /etc/resolv.conf and commenting out one of the servers

None of these changed anything, still resolvectl listed both DNS servers as available and when I performed my tests the DNS queries were split between the two servers instead of using only the one server I had specified.

How can I tell systemd to only use a single DNS server I specify, and not to also use the servers returned via DHCP?

  • still struggling with the same problem
    – M0nZDeRR
    Commented Jul 28, 2021 at 0:37
  • @M0nZDeRR I added a new answer, can you try it and let me know if it worked?
    – Malvineous
    Commented Jul 28, 2021 at 7:02

3 Answers 3


I haven't tried this but I have since found there is an option to ignore DNS servers coming from the DHCP response. In the systemd .network file, add a DHCP section if it doesn't already exist and use the UseDNS option:

DNS=  # Specify your DNS server manually

UseDNS=no  # Don't use DNS servers from DHCP
  • Didn't work for me, neither did andrea.corbellini.name/2020/04/28/ubuntu-global-dns But the DNS= should be in the Resolve section?
    – xeruf
    Commented Aug 26, 2023 at 20:46
  • According to man systemd.network the DNS= option belongs in [Network]. Are you rebooting your machine after making the changes? It's notoriously difficult to test systemd network changes without rebooting (it can be done for most things but it's very easy for it to look like your changes haven't worked, when you've just forgotten to restart one of the systemd subcomponents like systemd-resolved or restarted it before systemd-networkd instead of after, so rebooting is more reliable.)
    – Malvineous
    Commented Aug 27, 2023 at 5:37
  • Actually, it seems to work now, though I am not sure if it was this comment that made it work because I experimented with multiple suggestions. Yeah I usually tested by restarting these services.
    – xeruf
    Commented Sep 3, 2023 at 6:46

I don't have enough rep to comment on Malvineous's answer. While his answer is correct, nspawn containers need to name the file 80-container-host0.network to override the system defaults from the host.

From the systemd-nspawn docs:

Note that systemd-networkd.service(8) includes by default a network file /usr/lib/systemd/network/80-container-ve.network matching the host-side interfaces created this way, which contains settings to enable automatic address provisioning on the created virtual link via DHCP, as well as automatic IP routing onto the host's external network interfaces. It also contains /usr/lib/systemd/network/80-container-host0.network matching the container-side interface created this way, containing settings to enable client side address assignment via DHCP. In case systemd-networkd is running on both the host and inside the container, automatic IP communication from the container to the host is thus available, with further connectivity to the external network.


# https://www.freedesktop.org/software/systemd/man/systemd.network.html#UseDNS=
# Disable adding the DNS from DHCP



If you can set a static IP then you can specify the DNS server. Ask the network admins for a static IP you can use and try that. Do not use just any IP for that, you could easily end up with a duplicate.

You must log in to answer this question.

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