-
Disable and stop the systemd-resolved service:
sudo systemctl stop systemd-resolved -
Then put the following line in the
[main]section of your/etc/NetworkManager/NetworkManager.conf:dns=default rc-manager=symlinkIn this way we are using dns default in conjunction with rc-managed symlink:
dns=default: NetworkManager will update /etc/resolv.conf to reflect the nameservers provided by currently active connections. Default is used, unless /etc/resolv.conf is a symlink to /run/systemd/resolve/stub-resolv.conf, /run/systemd/resolve/resolv.conf, /lib/systemd/resolv.conf or /usr/lib/systemd/resolv.conf. In that case, systemd-resolved is chosen automatically.rc-manager=symlink: If /etc/resolv.conf is a regular file, NetworkManager will replace the file on update. If /etc/resolv.conf is instead a symlink, NetworkManager will leave it alone. Unless the symlink points to the internal file /run/NetworkManager/resolv.conf, in which case the symlink will be updated to emit an inotify notification. This allows the user to conveniently instruct NetworkManager not to manage /etc/resolv.conf by replacing it with a symlink. -
Delete
/etc/resolv.confrm /etc/resolv.conf -
Create your own
/etc/resolv.conf.customif you need to customize your DNSnameserver 8.8.8.8 nameserver 10.40.1.40 nameserver 10.40.1.41 -
Make a symbolic link:
sudo ln -s /etc/resolv.conf /etc/resolv.conf.custom -
Start the systemd-resolved service:
sudo systemctl start systemd-resolved -
Restart network-manager
sudo service network-manager restartOr
sudo systemctl restart NetworkManager.service
-
-
Save Ostico/c87257973c8b29715367ea22174fcc63 to your computer and use it in GitHub Desktop.
How to use a custom `resolv.conf` file with systemd-resolved in Ubuntu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment