How to configure DNS nameservers on Debian 11


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

Interfaces configuration file
The network interface configuration file located at /etc/network/interfaces

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.


Google DNS




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.