Changing DNS on EndeavourOS KDE Edition

Hey,
I have tried lots of way to change DNS and none worked so far.

I’ve tried systemd-resolved. This has this config but it has no effect, NetworkManager still uses Google DNS.

Global
           Protocols: +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported
    resolv.conf mode: foreign
  Current DNS Server: 1.1.1.1#cloudflare-dns.com
         DNS Servers: 1.1.1.1#cloudflare-dns.com 1.0.0.1#cloudflare-dns.com 2606:4700:4700::1111#cloudflare-dns.com
Fallback DNS Servers: 1.1.1.1#cloudflare-dns.com 9.9.9.9#dns.quad9.net 8.8.8.8#dns.google 2606:4700:4700::1111#cloudflare-dns.com
                      2620:fe::9#dns.quad9.net 2001:4860:4860::8888#dns.google

Link 2 (enp58s0)
    Current Scopes: none
         Protocols: -DefaultRoute +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported
       DNS Servers: 9.9.9.9 149.112.112.112

Link 3 (wlan0)
    Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6 mDNS/IPv4 mDNS/IPv6
         Protocols: +DefaultRoute +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 149.112.112.112
       DNS Servers: 149.112.112.112 9.9.9.9

/etc/resolv.conf still has 8.8.8.8 in it:

# Generated by NetworkManager

nameserver 8.8.8.8
nameserver 8.8.4.4

I’ve tried using settings UI, but it doesn’t let me save changes. the button is disabled

So what’s the actual proper way to do it? Different sources say different things, and none of them works. NM DNS still gets reset to Google DNS

misc info:

❯ uname -mprs
Linux 6.7.4-arch1-1.1-g14 x86_64 unknown
❯ NetworkManager --version
1.46.0-2

Post the output of

$ cat /etc/nsswitch.conf
# Name Service Switch configuration file.
# See nsswitch.conf(5) for details.

passwd: files systemd
group: files [SUCCESS=merge] systemd
shadow: files systemd
gshadow: files systemd

publickey: files

hosts: mymachines resolve [!UNAVAIL=return] files myhostname dns
networks: files

protocols: files
services: files
ethers: files
rpc: files

netgroup: files

Look at this line. The dns entry (this will use /etc/resolv.conf) is the last item on the list. If you have systemd-resolved.service enabled, the dns hostname look up will prioritize systemd-resolved because resolve appears before dns.

The [!UNAVAIL=return] basically says to return and ignore file, myhostname and dns if systemd-resolved is able to resolve the hostname. In other words, if systemd-resolved.service is enabled and running, host name resolution will follow the systemd-resolved settings—whatever DNS server you specified in systemd-resolved will be used.

Hint:
Use the dig or drill command or something to test which DNS is used.

systemd-resolved is running and enabled.

❯ sudo systemctl status systemd-resolved
● systemd-resolved.service - Network Name Resolution
     Loaded: loaded (/usr/lib/systemd/system/systemd-resolved.service; enabled; preset: enabled)
     Active: active (running) since Thu 2024-02-29 12:40:02 EET; 1h 12min ago
       Docs: man:systemd-resolved.service(8)
             man:org.freedesktop.resolve1(5)
             https://www.freedesktop.org/wiki/Software/systemd/writing-network-configuration-managers
             https://www.freedesktop.org/wiki/Software/systemd/writing-resolver-clients
   Main PID: 702 (systemd-resolve)
     Status: "Processing requests..."
      Tasks: 1 (limit: 37919)
     Memory: 8.4M (peak: 10.9M)
        CPU: 1.363s
     CGroup: /system.slice/systemd-resolved.service
             └─702 /usr/lib/systemd/systemd-resolved

However, Google DNS is still used when running dig:

 dig example.com

; <<>> DiG 9.18.24 <<>> example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 35963
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;example.com.                   IN      A

;; ANSWER SECTION:
example.com.            20071   IN      A       93.184.216.34

;; Query time: 43 msec
;; SERVER: 8.8.8.8#53(8.8.8.8) (UDP) # <---- here
;; WHEN: Thu Feb 29 13:54:11 EET 2024
;; MSG SIZE  rcvd: 56

That’s because dig is hardcoded to use /etc/resolv.conf by default.

Try drill instead.

I use

[main]
dns=none
systemd-resolved=none

In /etc/NetworkManager/conf.d/dns.conf

And set the nameservers in /etc/resolv.conf manually.

It works on my end.

Same thing, even nslookup shows google DNS:

❯ drill example.com
;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 19750
;; flags: qr rd ra ; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 
;; QUESTION SECTION:
;; example.com. IN      A

;; ANSWER SECTION:
example.com.    4107    IN      A       93.184.216.34

;; AUTHORITY SECTION:

;; ADDITIONAL SECTION:

;; Query time: 36 msec
;; SERVER: 8.8.8.8
;; WHEN: Thu Feb 29 13:56:08 2024
;; MSG SIZE  rcvd: 45

~ 
❯ nslookup example.com
Server:         8.8.8.8
Address:        8.8.8.8#53

Non-authoritative answer:
Name:   example.com
Address: 93.184.216.34
Name:   example.com
Address: 2606:2800:220:1:248:1893:25c8:1946

That doesn’t matter because he has systemd-resolved enabled.

Had this on both Arch nad on my fresh EndeavourOS (two days ago, fresh) install.

I’m using Controld dns.
I made changes to two files.
in /etc/systemd/resolved.conf
i changed the as follows

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it under the
#  terms of the GNU Lesser General Public License as published by the Free
#  Software Foundation; either version 2.1 of the License, or (at your option)
#  any later version.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in
# the resolved.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins.
#
# Use 'systemd-analyze cat-config systemd/resolved.conf' to display the full config.
#
# See resolved.conf(5) for details.

[Resolve]
# Some examples of DNS servers which may be used for DNS= and FallbackDNS=:
# Cloudflare: 1.1.1.1#cloudflare-dns.com 1.0.0.1#cloudflare-dns.com 2606:4700:4700::1111#cloudflare-dns.com 2606:4700:4700::1001#cloudflare-dns.com
# Google:     8.8.8.8#dns.google 8.8.4.4#dns.google 2001:4860:4860::8888#dns.google 2001:4860:4860::8844#dns.google
# Quad9:      9.9.9.9#dns.quad9.net 149.112.112.112#dns.quad9.net 2620:fe::fe#dns.quad9.net 2620:fe::9#dns.quad9.net

DNS=76.76.2.22#XXXXXXXXXXX.dns.controld.com
#FallbackDNS=1.1.1.1

#FallbackDNS=1.1.1.1#cloudflare-dns.com 9.9.9.9#dns.quad9.net 8.8.8.8#dns.google 2606:4700:4700::1111#cloudflare-dns.com 2620:fe::9#dns.quad9.net 2001:4860:4860::8888#dns.google
#Domains=
#DNSSEC=no
DNSOverTLS=yes
#MulticastDNS=yes
#LLMNR=yes
#Cache=yes
#CacheFromLocalhost=no
#DNSStubListener=yes
#DNSStubListenerExtra=udp:127.0.0.1:53
#ReadEtcHosts=yes
#ResolveUnicastSingleLabel=no
#StaleRetentionSec=0

Where the XXXXXXXXXX in your personal address provided by Controld

And I created a file in /etc/NetworkManager/conf.d/dns.conf

[main]
dns=none
systemd-resolved=false

sudo systemctl enable systemd-resolved.service
sudo systemctl start systemd-resolved.service

And my DNS was working as desired with ControlD

I don’t know what changes occur with both Arch and Endeavour, as the intructions provided by ControlD miss out on the dns.conf creation.

And EndeavourOS required the enabling systemd-resolved.service

But, it works for me.

It shouldn’t use systemd-resolved.

It will in this case. See the contents of his /etc/nsswitch.conf

If you are using systemd-resolved.service, you have two options. Either use a stub resolver, which will symlink your /etc/resolv.conf to the stub provided by systemd, or set the DNS servers manually.

It’s all here.

https://wiki.archlinux.org/title/systemd-resolved#Manually

Alright I’ll rephrase my original question. How do I set Cloudflare DNS or Quad9 on EOS? I don’t care if through systemd-resolved or anyhow else. I just want it to work, so that my custom DNS is used.

Easiest way is to disable systemd-resolved.service, and then set the DNS servers in network manager directly. See @pebcak 's answer.

Edit:

Personally, I set up my DNS servers manually using systemd-resolved in order to take advantage of caching.

To set your DNS servers in systemd-resolved, you simply have to add this file /etc/systemd/resolved.conf.d/dns.conf with the following contents:

[Resolve]
DNS="put your DNS ip here"
Fallback="put your fallback DNS ip here"
Domains=~.
2 Likes

Finally, it worked. I’ve stopped and disabled systemd-resolved and directly edited /etc/resolv.conf. What a mess DNS is on Linux…

This might be a better option.

On my end, however, I use dnscrypt-proxy and it has dns caching by default as well.

1 Like

This is not recommended. Because networkmanager will automatically regenerate this file every time you reboot. In order to get network manager to generate the correct DNS ips, you have to tell NetworkManager to do so. The only way to do that is to configure DNS on NetworkManager. If you are using a gui like network manager applet, you can probably do it graphically. But if you want to do it manually, you can check out the Arch Wiki:

https://wiki.archlinux.org/title/NetworkManager#Custom_DNS_servers

Never heard of this before. But I will look into this. Thanks for sharing.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.