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:
- Method 1: Finding the Currently Used DNS Nameservers by Reading the /etc/resolv.conf File
- Method 2: Finding the Currently Used DNS Nameservers Using Resolvconf
- Method 3: Finding the Currently Used DNS Nameservers Using Resolvectl
- 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.
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.