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 1.1.1.1
and 1.0.0.1
. You can add multiple nameservers separate by whitespace, but the first DNS nameserver will be the default one.
dns-nameservers 1.1.1.1 1.0.0.1

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.
CloudFlare 1.1.1.1 1.0.0.1
Google DNS 8.8.8.8 8.8.4.4
Quad9 9.9.9.9 149.112.112.112
OpenDNS 208.67.222.222 208.67.220.220
HDNS 103.196.38.38 103.196.38.39 103.196.38.40
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.
cat /etc/resolv.conf
If everything is configured correctly, you’ll see the DNS nameservers updated to CloudFlare. Otherwise, reboot the server for changes to take effect.
nameserver 1.1.1.1 nameserver 1.0.0.1