On Debian, you can change the DNS server with a few simple commands or via the graphical user interface (GIU). Making changes directly in the Internet router also allows you to change the provider’s default DNS server.
Debian: change DNS server in network settings¶
If you work with a GUI, you can change the DNS server directly in Debian settings.
Step 1 : go to network settings and then select the gear symbol next to internet connection.
2nd step : under the IPv4 and IPv6 tabs, you then have the option of adding a new DNS server. If you want to use multiple alternate servers, separate them with a comma.
Debian: change the DNS server in the configuration file¶
You can also change the DNS server on Debian via the command line. To do this, open the terminal.
Step 1 : if you are not already logged in as the root user, you still need to obtain root rights. Then enter the following line of code:
2nd step : the file responsible for name resolution is resolv.conf. In principle, it is possible to insert new DNS servers there. However, this file is managed by the system and is therefore regularly overwritten. To avoid this deletion, it is necessary toinstall the resolvevconf program. Perform the requested updates:
apt update
apt upgrade
apt install resolvconf
bash
Step 3: check if the program is already running.
systemctl status resolvconf.service
bash
If the program is running, then the code “active” should be displayed there. If not, you can run the program with the following commands:
sudo systemctl start resolvconf.service
sudo systemctl enable resolvconf.service
sudo systemctl status resolvconf.service
bash
Step 4: you now need to modify the main document of this program. To do this, open the file with a text editor, for example Nano:
nano /etc/resolvconf/resolv.conf.d/head
bash
In this file, now register the DNS server(s) of your choice. Many users, for example, choose Google’s DNS offer. In this case, enter the two IP addresses of Google’s DNS server:
nameserver 8.8.8.8
nameserver 8.8.4.4
bash
Save and close the file.
Step 5: all you have to do is update file resolv.conf. To do this, use the following command:
resolvconf --enable-updates
resolvconf -u
bash
In opening the file resolv.confyou should now be able to see the two integrated servers.
nano /etc/resolv.conf
bash
Now you have changed the DNS servers in Debian permanently.
Debian: change the DNS server in the router¶
You can also change the DNS server directly in your router. The advantage of this method is that the DNS servers of all devices on your network will be adapted. So you don’t have to configure all PCs, laptops, smartphones and tablets individually.
As a rule, you access your router’s configuration via a special URL, which you will find in your router’s user manual. You can also view the access data there. In the case of a Fritz!Box for example, you access theuser interface via « http://fritz.box/ ». In the Internet access settings, you will also find the DNS server settings.
Why change DNS server in Debian?¶
The Domain Name System (DNS) allows you to use domain names instead of IP addresses to search the Internet. This is made possible thanks to the DNS server, which allows your computer to access the requested information. By default, the DNS server of the Internet service provider is used for this. However, you can modify it, in particular for the following reasons:
- DNS server not responding: If the DNS server you are using goes down, change the server to another alternative so you can continue to use the Internet.
- Bypass internet censorship: some countries use DNS to block unwanted websites; an alternative DNS server makes it possible to circumvent this blocking.
- Improve browsing speed: there are DNS servers that promise particularly fast connections.
Other operating systems also allow changing DNS servers, either with Windows or Linux: