There can be only one entry that writes/managed /etc/resolv.conf
.
For example, NetworkManager
or the human administrator.
There is also resolvconf
, which is a tool that accepts multiple sources for DNS configuration, and then merges them into one /etc/resolv.conf
.
By default, NetworkManager runs with [main].rc-manager=symlink
setting. See man NetworkManager.conf
. Unless you changed that configuration, NetworkManager won't touch the file. Read also about [main].dns=
setting.
In general, you need to make up your mind about what should configure it, and then configure all related software to agree on that. Since NetworkManager by default already leaves the file alone, if it's a symlink, you don't need to tell NetworkManager to stay off.
If you use one of the GUIs to configure DNS, then those GUIs actually configure the profile in NetworkManager. That only works, if NetworkManager is instructed to write /etc/resolv.conf
Commonly systemd-resolved
is used. Resolved doesn't write /etc/resolv.conf
, but it can consume it as input. If you use that, usually /etc/resolv.conf
should be just a symlink as documented in /ETC/RESOLV.CONF
section in man systemd-resolved
. In that case, NetworkManager can push it's DNS configuration to systemd-resolved
. Run resolvectl
to see that configuration in systemd-resolved
.
Changing /etc/dhcp/dhclient.conf
seems quite wrong. Especially, if you use NetworkManager which by default doesn't use dhclient. In any case, injecting the DNS setting in the DHCP client is not right. In NetworkManager, you configure DNS by setting it in NetworkManager's connection profiles (+ setup your system and NetworkManager to do the right thing with those settings).
There is not one answer, because it depends on how exactly you want to set up your system. Commonly you would stick to what your distro provides you with. Understand what your distro is setup to do, and use the appropriate mechanisms in that case. Who created /etc/resolv.conf
as a symlink, and why did it do that? (Neither NetworkManager nor systemd-resolved would do that).