How to see DNS in Linux

DNS or Domain Name System lets you turn easy-to-read website address in the ip address of the server that is hosting this website. For this purpose, the DNS servers that contain mappings of ip addresses to their domain names. By default, the system gets the address of the DNS server automatically by DHCP when you connect to the network.

In this article we will understand how to see what DNS servers are used on Linux.

How to see DNS in Linux

If you have already had the experience of network configuration in Linux, then you know that DNS servers used for resolving domain names specified in the file /etc/resolv.conf:

sudo vi /etc/resolv.conf

But in modern Linux distributions with systemd init system usually are running a local DNS server, the address of which is registered in this file and which servers are actually unclear. In this case, you can use the systemd-resolve:

systemd-resolve --status

At the bottom of the output tool you can view DNS in Linux that are now used. Information is displayed for each network interface separately.

To solve this problem you can use the nmcli tool:

nmcli dev show | grep DNS

As you can see, it’s very simple. And to change the DNS server also touch /etc/resolv.conf is not desirable, as it will be automatically updated after a reboot. If you are using NetworkManager, you can configure DNS for your network connection in the interface. Or you can edit the file /etc/systemd/resolved.conf and add the desired address to the section Resolve:

sudo vi /etc/systemd/resolved.conf


As you can see, it’s very simple. I hope this information was useful for you.


(Visited 96 times, 1 visits today)