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 al­tern­at­ives, separate them by a comma.

Image: Network settings with option to enter DNS servers in Debian
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 con­fig­ur­a­tion 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 priv­ileges first:

su
bash

Step 2: the nameserv­er entries are located in the resolv.conf file. Tech­nic­ally this is where new DNS servers can be inserted. However, this file is managed by the system and gets over­writ­ten regularly. To prevent these rewrites from happening, you must install the resolv­conf program. Otherwise, the system will continue being updated as usual:

apt update
apt upgrade
apt install resolvconf
bash

Step 3: check if the program has already started:

systemctl status resolvconf.service
bash

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
bash

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
bash

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:

nameserver 8.8.8.8
nameserver 8.8.4.4
bash
Image: The resolvconf head document with Google’s DNS servers entered
Enter the data for the nameserv­ers 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
bash

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

nano /etc/resolv.conf
bash

Now you have suc­cess­fully changed the DNS server on Debian.

How to set DNS servers using your router

Al­tern­at­ively, 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 sep­ar­ately.

You can usually access the con­fig­ur­a­tion settings of your router via a URL, which can be found in the router’s manual. The manual also contains the login cre­den­tials to access the settings. For example, with a Fritz!Box router, you can access the con­fig­ur­a­tion interface by going to ‘http://fritz.box/’. The DNS settings can be found under ‘Account In­form­a­tion’ in the internet settings section.

Image: Settings for setting DNS servers in router Fritz!Box 7590
In this router model of Fritz!Box, the settings for con­fig­ur­ing DNS servers can be found under ‘Account In­form­a­tion’ 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 man­u­fac­turer.

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 nav­ig­at­ing the web. Using this system, DNS servers provide your computer (or any other device) with the in­form­a­tion 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:

  • Over­load­ing: if you receive the error message that your DNS server is not re­spond­ing, the server you are using might be tem­por­ar­ily offline.
  • Bypass cen­sor­ship: some countries use the DNS servers assigned by internet providers to censor in­form­a­tion.
  • Speed: some DNS servers can provide a faster internet con­nec­tion.
Go to Main Menu