Installing resolvconf in Ubuntu and Debian to set Permanent DNS Nameservers in
Ubuntu and Debian
Unfortunately, because the /etc/resolv.conf is indirectly managed by the
systemd-resolved service, and in some cases by the network service (by using
initscripts or NetworkManager), any changes made manually by a user can not be
saved permanently or only last for a while.
-
Update the system software packages and then install resolvconf from the official repositories by running the following commands.
sudo apt update<br/>sudo apt install resolvconf -
Start and enable
resolvconf.servicesudo systemctl start resolvconf.service sudo systemctl enable resolvconf.service<br/>sudo systemctl status resolvconf.service -
Set Permanent DNS Nameservers and search domain
sudo cat <<EOT >> /etc/resolvconf/resolv.conf.d/head nameserver 172.16.29.3 nameserver 1.1.1.1 nameserver 8.8.8.8 search nginxf5.com EOT -
Check the file
cat /etc/resolvconf/resolv.conf.d/head -
Save the changes and restart the resolvconf.service or reboot the system.
sudo systemctl start resolvconf.service