How to Find the Currently Used DNS Nameservers of Linux

DNS nameservers play a crucial role in resolving the DNS names into IP addresses. It’s an important part of the internet. Without DNS nameservers, you will have to remember the IP address of the Google web servers instead of the easy-to-remember DNS name like google.com (let’s say) if you want to visit Google. So, you must have the working DNS nameservers configured on your Linux system for the internet to work.

In this article, we will show you the different methods of finding the currently used DNS nameservers of the most popular Linux distributions, i.e. Ubuntu, Debian, Linux Mint, Fedora, RHEL, Rocky Linux, etc.

Topic of Contents:

  1. Method 1: Finding the Currently Used DNS Nameservers by Reading the /etc/resolv.conf File
  2. Method 2: Finding the Currently Used DNS Nameservers Using Resolvconf
  3. Method 3: Finding the Currently Used DNS Nameservers Using Resolvectl
  4. Conclusion

Method 1: Finding the Currently Used DNS Nameservers by Reading the /etc/resolv.conf File

On every Linux distribution (i.e. Ubuntu/Debian/Linux Mint, Fedora, CentOS/RHEL/Rocky Linux, etc.) you can find the currently used DNS nameservers just by reading the “/etc/resolv.conf” file as follows:

The currently used primary and secondary DNS nameservers should be printed.

As you can see, our Debian 12 Linux distribution is using the primary DNS nameserver 1.1.1.1 and the secondary DNS nameserver 8.8.8.8.

A screen shot of a computer Description automatically generated

Method 2: Finding the Currently Used DNS Nameservers Using Resolvconf

If you’re using the Debian server operating system or other Linux distributions that use resolvconf to manage the DNS nameservers using the “/etc/network/interfaces” configuration file, you can find the currently used DNS nameservers with the following command:

The currently used primary and secondary DNS nameservers of your Linux distribution should be listed. In our case, the primary DNS nameserver is 1.1.1.1 and the secondary nameserver is 8.8.8.8.

Method 3: Finding the Currently Used DNS Nameservers Using Resolvectl

If you’re using Ubuntu, Fedora, or other Linux distributions that use the Network Manager to manage the network configuration, you can use the “resolvectl” command to find the currently used DNS nameservers of your Linux system:

Conclusion

In this article, we showed you how you find the currently used DNS nameservers of your Linux system by reading the “/etc/resolv.conf” file and using the “resolvconf” and “resolvctl” commands.

source

Leave a Comment