Some people are interested in changing the default DNS nameservers provided by their VPS provider to their preferred ones, such as Google, CloudFlare, or Quad9. This tutorial will guide you to do it on Debian 11 within a few steps.
Installing the resolvconf package
Install the resolvconf package using the following command first.
resolvconf will help configure DNS nameservers easily if the
dns-nameservers option is present in the network interfaces configuration file.
sudo apt-get update sudo apt-get install resolvconf
Editing the network interfaces configuration file
Open the network interfaces configuration file located at
/etc/network/interfaces with a text editor of your choice.
sudo vi /etc/network/interfaces
Add the following line to the IPv4 network interface. I’ll change it to the CloudFlare ones which are
18.104.22.168. You can add multiple nameservers separate by whitespace, but the first DNS nameserver will be the default one.
dns-nameservers 22.214.171.124 126.96.36.199
Save changes and restart the
networking service using the following command.
sudo systemctl restart networking
Here is a list of well-known DNS nameservers. In case you prefer something else other than CloudFlare.
188.8.131.52 184.108.40.206 220.127.116.11
Checking the resolv.conf file
Check the resolv.conf file located at
/etc/resolv.conf using the
cat command if the DNS nameservers have been updated.
If everything is configured correctly, you’ll see the DNS nameservers updated to CloudFlare. Otherwise, reboot the server for changes to take effect.
nameserver 18.104.22.168 nameserver 22.214.171.124