You are not logged in.

#1 2020-09-07 17:36:55

thefiercerabbit
Member
Registered: 2016-09-29
Posts: 13

[SOLVED] systemd-resolved -- do not use DNS from DHCP

I want to use systemd-resolved (using the systemd DNS stub file) and configure my DNS servers manually. However, as you can see below, the DNS 192.168.64.1 (obtained via DHCP) is present in the list of DNS servers for the interface eth0.

$ resolvectl
Global
       LLMNR setting: yes                 
MulticastDNS setting: yes                 
  DNSOverTLS setting: no                  
      DNSSEC setting: no                  
    DNSSEC supported: no                  
  Current DNS Server: 1.1.1.1             
         DNS Servers: 1.1.1.1             
                      1.0.0.1             
                      2606:4700:4700::1111
                      2606:4700:4700::1001
Fallback DNS Servers: 1.1.1.1             
                      9.9.9.10            
                      8.8.8.8             
                      2606:4700:4700::1111
                      2620:fe::10         
                      2001:4860:4860::8888
          DNS Domain: ~.                  

Link 2 (eth0)
      Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
DefaultRoute setting: yes                      
       LLMNR setting: yes                      
MulticastDNS setting: no                       
  DNSOverTLS setting: no                       
      DNSSEC setting: no                       
    DNSSEC supported: no                       
  Current DNS Server: 127.0.0.1                
         DNS Servers: 127.0.0.1                
                      192.168.64.1 

Below is the content of the file /etc/systemd/network/eth0.network.

[Match]
Name=eth0

[Network]
DHCP=yes
DNSSEC=no
UseDNS=false
DNS=
DNS=127.0.0.1

The documentation says that setting "DNS=" (the first one with the empty string) clears all previous assignments.

So, what is telling systemd-resolved to use the DNS from DHCP? How can I get rid of it while keeping systemd-resolved?

If needed, here is the content of /etc/systemd/resolved.conf.d/dns_servers.conf.

[Resolve]
DNS=1.1.1.1 1.0.0.1 2606:4700:4700::1111 2606:4700:4700::1001
Domains=~. 

Last edited by thefiercerabbit (2020-09-07 19:15:11)

Offline

#2 2020-09-07 19:14:54

thefiercerabbit
Member
Registered: 2016-09-29
Posts: 13

Re: [SOLVED] systemd-resolved -- do not use DNS from DHCP

As it is often the case, you go to the doctor and you already feel better.

I solved my issue by updating the file /etc/systemd/network/eth0.network as follows.

[Match]
Name=eth0

[Network]
DHCP=yes
DNSSEC=no

[DHCP]
UseDNS=false

You will notice that "UseDNS=false" is now under the section "[DHCP]", which was not present before! There's no need to set "DNS=" or "DNS=127.0.0.1" anymore, the global DNS will be used.

Offline

#3 2023-08-26 20:48:50

xerus
Member
Registered: 2021-05-11
Posts: 35

Re: [SOLVED] systemd-resolved -- do not use DNS from DHCP

Hm I got the same issue, but I'd like to apply this setting for any network and any interface, suggestions?
Tried these without success:
https://andrea.corbellini.name/2020/04/ … lobal-dns/
https://unix.stackexchange.com/question … -i-specify

Offline

#4 2023-08-26 21:40:45

seth
Member
Registered: 2012-09-03
Posts: 58,698

Re: [SOLVED] systemd-resolved -- do not use DNS from DHCP

Add a network rule that matches "Name=*"?

Please don't necrobump, you technically don't even have the same question as the OP ("how do I apply networkd rules to every device" ./. "how to ignore dhcp issued dns")

Offline

Board footer

Powered by FluxBB