Editing resolv.conf no longer changes my DNS servers — what replaced it?
I want my server to use a public resolver rather than the one my hosting provider hands out. On older systems I would edit /etc/resolv.conf, restart a service and be done.
On a current release that no longer works. My edits survive for a while and then the file goes back to what it was, and the nameserver listed in it is a local loopback address rather than anything I recognise.
So something else is managing this now. What is it, and what is the correct place to make the change so that it persists?
@sysadmin_selin · 2d ago
The loopback address in
resolv.confis the clue: your system is running a local stub resolver, and/etc/resolv.confis now a generated file pointing at it rather than a configuration file you own.On most current systemd-based distributions that resolver is
systemd-resolved. The chain is:/etc/resolv.conf.So editing step 1 changes nothing meaningful, and the file gets regenerated because it is an output.
The correct place to make the change is the resolver's own configuration —
/etc/systemd/resolved.conf, where you set theDNS=line to your chosen upstream servers, then restart the service. After that,resolvectl statuswill show you the upstream actually in use, which is the command to trust rather than reading the file.Reply
Report