I am trying to manually set /etc/resolv.conf
I understand systemd is overriding this. All I want to do is put in a manual setting, period.
I tried numerous things. The only thing that worked was to remove the link, set the file, and set it to no overwrite. That’s surely a hack. I want to do it right.
I tried going into /etc/systemd/resolved.conf and setting:
And rebooting. That didn’t work.
There has got to be a simple way of doing this. Help would really be appreciated.
What leads you to believe that ‘systemd’ is changing this? Fedora (non-server) systems typically use NetworkManager to manage the network configuration, including resolver configuration.
Let’s back up a bit: which tool are you using to manage the network interface that connects you to this DNS resolver?
I understand about NetworkManager. I just think systemd is driving it.
I installed Fedora 36 Mate. Whatever it does by default is what I am doing. Until recently, I never touched it. Now, I am having a DNS issue and wanted to manually set which server is used. Used to be, you just set it in resolv.conf. That doesn’t work anymore. If you check the net you get “try this”, “try that”. I tried it all. The only thing that works was the awful hack I described above.
Manually setting the DNS server should be trivial. It has become a nightmare.
Thanks for the help!
NetworkManager comes with a gui configuration program where you can set the DNF server among other things. Since dns is now handled by systemd-resolved, the content of /etc/resolv.conf has become irrelevant in most cases.
So, you configure the DNS in NetworkManager, and NetworkManager will do whatever it takes to pass on this information to systemd-resolved.
Yep, Villy has it right. Go into NetworkManager’s configuration tool (depending on where that lives in your desktop environment), find the connection that needs to be changed (wired, wifi, VPN, etc.), and disable ‘auto’ DNS replacing it with your desired address.
NetworkManager will then feed that information into the other places it is required when the connection is activated. Trying to manipulate that data at a lower level will lead to frustration since it is part of the ‘managed’ network connection.
How can I tell what addresses it is using from the command line?
If the system is using
systemd-resolved for DNS resolution, then the
resolvectl command will give you all of the information about what it is using to resolve names.
The bad guy creating the /etc/resolv.conf link is revealed by
“rpm -q --scripts systemd-resolved”, so upon systemd-resolved update the link is recreated. If you really want or need the classical /etc/resolv.conf, the recipe is there: stop and disable systemd-resolved. But since systemd-resolved is more flexible and integrates with NetworkManager, better to configure and use it!
Yes, it creates the link. No it does not do so upon an upgrade if /etc/resolv.conf already exists.
Thus a manually created file at that location does not get removed with system updates.
I agree that manual changes should be put into the NetworkManager configuration tool as previously suggested. However, manually creating a file at /etc/resolv.conf and replacing the link there is actually a valid way of managing dns. The drawback is that any dns config done using the configuration tool is not seen by the system once the link has been replaced.
Agree, now in F37 I can reinstall systemd-resolved without loosing the manually created symlink. Only initial installation of systemd-resolved creates link now. (Two lines of code added above the comment block.)
Sorry for the wrong information.
According to “resolvectl status” the “resolv.conf mode” switches to foreign and the DNS parameter is taken from resolv.conf.
Unfortunately (or maybe fortunately depending upon your viewpoint) once a user has created that file to replace the symlink it effectively relegates systemd-resolved to an ineffective and unused status.
Only if you also remove “resolve [!UNAVAIL=return]” from the “hosts:” line in /etc/nsswitch. The entries in /etc/resolv.conf will be used by systemd-resolved to set the dns server.
You may also need to update NetworkConfig.conf to define what it is supposed to do with the dhcp information.
As far I understood, programs can do DNS lookup themselves or call library functions. In order to have consistent behaviour between the two, either /etc/resolv.conf should be a symbolic link and systemd-resolved active, or a classical /etc/resolv.conf file with systemd-resolved inactive/deactivated.
Proof: /etc/resolvconf contains nameserver 220.127.116.11, systemd-resolved gets DHCP info:
;router.home. IN A
; SERVER: 18.104.22.168#53(22.214.171.124) (UDP)
ping -4 router.home
64 bytes from _gateway (192.168.2.254):
So dig uses /etc/resolv.conf and gets 126.96.36.199, ping the library lookup from systemd-resolved and uses the DHCP assigned nameserver.
dig @127.0.0.53 router.home
router.home. 0 IN A 192.168.2.254
Firefox: http://router.home opens modem configuration page.
and NO. Nothing with systemd writes to /etc/resolv.conf. At startup the data is placed under /run/systemd/resolve/. That is why I said systemd-resolved becomes ineffective. Any information it retrieves and places in the /run/systemd/resolve/ tree related to dns is negated by having a user created file at /etc/resolv.conf instead of the symlink.
The dns related info returned by dhcp is still stored as intended but the user created file no longer directs the system to that since /etc/resolv.conf is now a file and not a link.
Network related info from dhcp still is managed by NetworkManager and systemd-resolved as intended. Only the DNS info is overridden (or rather no longer accessed).
Access with other programs that have been updated to directly access the systemd-resolve files and functions but do not directly access /etc/resolv.conf may exhibit a hybrid effect as shown by @hmmsjan above, but pure dns lookups for name service (such as browsers) use (in order) /etc/hosts, /etc/resolv.conf, then to the dns nameservers identified there. If /etc/resolv.conf does not point to the local systemd-resolved service then it never gets used for normal name service.
man systemd-resolved says, among other things
• Alternatively, /etc/resolv.conf may be managed by other packages, in
which case systemd-resolved will read it for DNS configuration data.
In this mode of operation systemd-resolved is consumer rather than
provider of this configuration file.
Also, /etc/nsswitch directs normal name lookups to systemd-resolved via the “resolve” entry. Some programs may bypass the nsswitch facility and access the dns server directly as directed by /etc/resolv.conf. So for these programs systemd-resolved would not be used.
Sorry, It’s still not clear for me.
In firefox, http://router.home gives me the router configuration page. This page is not known to 188.8.131.52 and can only be resolved by systemd-resolved.
Even a name-only lookup to a Windows PC works, which should be LLMNR.
As soon I stop systemd-resolved, the “router.home” is no longer known, but internet lookup works and originates from 184.108.40.206.
Is it not the other way around: if systemd-resolved is running, /etc/resolv.conf is not used for normal lookups, except, as @vekruse mentions , systemd-resolved uses it as consumer to define the DNS parameter.
Protocols: +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: foreign
Current DNS Server: 220.127.116.11
DNS Servers: 18.104.22.168
Link 2 (wls1)
Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 192.168.2.254
DNS Servers: 192.168.2.254 fe80::b2ac:d2ff:fe57:410e%32655
DNS Domain: home