The DNS configuration in Debian

So today we will talk with you about setting up DNS in Debian. Those who are “in the know”, do not need explanation, but for the rest of the small walk. What is DNS? This is a computer distributed system for information about domains. It is used to obtain the IP address of that same cozy Gichki, or VC. Need it primarily for humans, since we, oddly enough, easier to remember address in letter format than in the numeric. But this is not the only plus.

Earlier the network was much smaller and present on each machine was the file hosts, it was sent automatically and “centralized”. He was responsible for converting between domain and IP addresses, but the network is continuously growing, and this method has obviously not coped with the tasks. Here comes in a mechanism that is able to do all the same and in large volumes — DNS. With definitions understood, now get to the essence of the article.

The DNS configuration in Debian

First we will look at the file /etc/resolv.conf. This is the main configuration file library name resolver DNS. The resolver is a library in the language C, it provides access to DNS for programs in the system.

Its functions are configured to the following:

  • On checking the records in the file /etc/hosts or multiple DNS servers;
  • To use the database hosts NIS (Information network service);

In modern Linux systems that use systemd, the local applications access DNS through a daemon systemresolved. By default, this service has four different modes and uses the default file-stub. It path: /run/systemd/resolve/stub-resolv.conf.

This file is used as the only DNSserver plug —, which redirects the address to the local DNS server and it in turn has received information from other servers on the Internet. I hope you get the idea.

Unfortunately, due to the fact that /etc/resolv.conf not directly managed by service systemd-resolved, and sometimes using initscripts or NetworkManager, any custom changes will NOT be saved. With all the difficulties described above, I want to share with you information about how to configure DNS on Debian in that ill-fated file /etc/resolv.conf.

Step 1. The contents of /etc/resolv.conf

To do this we open the terminal and write the command:

cat /etc/resolv.conf

There we see the server name nameserver and nothing more. It is yet, but we will return to.

Step 2. Install resolvconf

Be sure to update the system with the command:

sudo apt update

After the updates are installed resolvconf. For this we write the command:

sudo apt install resolvconf

After installation, the system should automatically start the service resolvconf.service. To check this you will need to use the command:

sudo systemctl status resolvconf.service

Here we see that the service is not running, but sometimes the trigger fires automatically. Anyway, we need to start this service. Use the following command:

sudo systemctl start resolvconf.service

sudo systemctl enable resolvconf.service

sudo systemctl status resolvconf.service

As you can see, using sudo systemctl start resolvconf.service and sudo systemctl enable resolvconf.service we start the service, sudo systemctl status resolvconf.the service will display the activity status of this service.

Step 3. Configuring DNS

Now open the file /etc/resolvconf/resolv.conf.d/head. This is done with the command:

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

Well, the next step is entering data into this file. Enter the following lines as shown in the screenshot:


Save the changes with ctrl+o -> Enter -> ctrl+x. Now we have to restart the system before the changes come into effect.

Step 4. Check the file /etc/resolv.conf

After restarting again open the terminal and write the command to start the service (this is a secondary measure, I, for example, the trigger load immediately):

sudo systemctl start resolvconf.service

See that the service is running. Go to the config file that was described at the beginning of the article. Use the command:

cat /etc/resolv.conf

In the screenshot displayed the same data that we introduced in the file — servername and servername That’s it! Setting DNS Debian is completed. Quite easy and simple, and most importantly, it works.


(Visited 983 times, 14 visits today)