What actually reads /etc/resolv.conf
Finding the owner in about a minute
BASH
# Is it a regular file or a symlink, and where does it point?
ls -l /etc/resolv.conf
# Generated files usually say who generated them in the first lines
head -n 5 /etc/resolv.conf
# Which managers are running?
systemctl is-active systemd-resolved NetworkManager systemd-networkd
# Is cloud-init present, and is netplan in use?
cloud-init status 2>/dev/null
ls /etc/netplan/ 2>/dev/null
# If systemd-resolved is active, see which upstream servers it uses per link
resolvectl status| Fingerprint | Owner | Where to set DNS |
|---|---|---|
| Symlink to /run/systemd/resolve/stub-resolv.conf, nameserver 127.0.0.53 | systemd-resolved | resolved.conf drop-in, or netplan / systemd-networkd for the link |
| Comment saying Generated by NetworkManager | NetworkManager | nmcli connection settings |
| Symlink to /run/resolvconf/resolv.conf, header mentioning resolvconf(8) | resolvconf | Interface config that feeds resolvconf |
| Plain file rewritten on lease renewal, dhclient running | dhclient-script | dhclient.conf |
| /etc/netplan/50-cloud-init.yaml exists, cloud-init active | cloud-init generating netplan | cloud-init config, or disable its network rendering |
systemd-resolved: the stub and the real list
INI
# /etc/systemd/resolved.conf.d/dns.conf
[Resolve]
DNS=1.1.1.1 9.9.9.9
# Optional: send all queries to the global servers above,
# not only queries that match no link-specific domain
Domains=~.NetworkManager: connection profiles win
BASH
# Find the profile name first
nmcli connection show
# Set static DNS and ignore DHCP-provided servers for IPv4
nmcli connection modify 'System eth0' ipv4.dns '1.1.1.1 9.9.9.9' ipv4.ignore-auto-dns yes
# Re-activate the profile to apply (briefly interrupts this interface)
nmcli connection up 'System eth0'