How to set DNS servers on Debian

You can set your DNS server on Debian using only a few commands or by using your computer’s interface, or GUI. A third way to do this is to make the changes via your internet router.

How to set your DNS server on Debian in the network settings

If you want to set the DNS server without the command prompt, you can do it directly through the settings.

Step 1: go to the network settings and click on the symbol for further settings (the cogwheel).

Step 2: you can enter a new DNS server under the IPv4 and IPv6 tabs. If you wish to use multiple server alternatives, separate them by a comma.

With Debian’s GUI, you can easily add the DNS servers of your choice in the DNS field.

How to set your DNS server using the configuration file

You can also set the DNS server in Debian via the command-line. To do this, open the terminal.

Step 1: if you are not already logged in as root, you need to get root privileges first:


Step 2: the nameserver entries are located in the resolv.conf file. Technically this is where new DNS servers can be inserted. However, this file is managed by the system and gets overwritten regularly. To prevent these rewrites from happening, you must install the resolvconf program. Otherwise, the system will continue being updated as usual:

apt update
apt upgrade
apt install resolvconf

Step 3: check if the program has already started:

systemctl status resolvconf.service

The status of the program should be displayed as ‘active’. If this is not the case, you can activate the service with the following commands:

systemctl start resolvconf.service
systemctl enable resolvconf.service
systemctl status resolvconf.service

Step 4: next you’ll customize the head document of this service. First, open the file, for example, with the nano editor:

nano /etc/resolvconf/resolv.conf.d/head

Now, enter the DNS server(s) you want into this file. For example, many people like to use the public DNS servers offered by Google. To use them, you need to enter the following IP addresses:

Enter the data for the nameservers you would like to use.

Save and close the file.

Step 5: Lastly, you just need to update the resolv.conf file. To do this, use the following command:

resolvconf --enable-updates
resolvconf -u

Now when you open the resolv.conf file, these two services should be inserted:

nano /etc/resolv.conf

Now you have successfully changed the DNS server on Debian.

How to set DNS servers using your router

Alternatively, you can change the DNS server directly in your router. The advantage of this method is that it’ll allow all devices in your network to use the same DNS server(s), without you having to configure each device separately.

You can usually access the configuration settings of your router via a URL, which can be found in the router’s manual. The manual also contains the login credentials to access the settings. For example, with a Fritz!Box router, you can access the configuration interface by going to ‘’. The DNS settings can be found under ‘Account Information’ in the internet settings section.

In this router model of Fritz!Box, the settings for configuring DNS servers can be found under ‘Account Information’ in the internet setting section.

Check your internet router provider’s manual or website for how to set DNS on Debian as this can vary per manufacturer.

Why should you set another DNS server on Debian?

The Domain Name System, or DNS, makes it possible to use domain names instead of IP addresses when navigating the web. Using this system, DNS servers provide your computer (or any other device) with the information it needs to surf the web. Many users rely on a default DNS server given to them by their internet provider, but there are good reasons to change DNS servers:

  • Overloading: if you receive the error message that your DNS server is not responding, the server you are using might be temporarily offline.
  • Bypass censorship: some countries use the DNS servers assigned by internet providers to censor information.
  • Speed: some DNS servers can provide a faster internet connection.
Page top