Linux Commands

How to Find My DNS Server IP Address in Linux

The DNS server is used to translate the web address strings into the corresponding IP addresses. DNS was introduced to make it easy to remember the web URLs because IP addresses are hard to keep in mind. Every URL has a DNS IP; in this guide, we will cover how to find a DNS server IP address in Linux.

How to Find My DNS Server IP Address in Linux

We have two different ways to find out the DNS Server IP address in the Linux operating system:

  1. Via the Command-line Interface
  2. Via the Graphical User Interface (GUI)

We will perform this task on the Ubuntu 22.04 version.

How to Find DNS Server IP Address Using Command-Line Interface

In Linux distributions, there are always multiple command-line utilities to execute any specific task. Similarly, to check the DNS Server IP Address, several commands are here:

  1. Through /etc/resolv.conf File
  2. Through nmcli Command
  3. Through dig Command

Before getting started with all of the above commands, make sure to update all of the system packages:

sudo apt update && sudo apt upgrade

Let’s run command-line utilities to display the result:

1. Find DNS Server IP Address Through /etc/resolv.conf File

There are multiple command tools to access the /etc/resilv.con file such as cat, less, and grep. 1

1. Using the cat command

The Concatenate (cat) command helps to display the content of a file as a standard output. It is also useful to print the DNS Server IP Address in the terminal:

sudo cat /etc/resolv.conf


Note that 127.0.0.53 is a loopback address, in this case forwarding the request to the DNS server which can be found using the following command:

resolvectl status

In the output, you can see the DNS IP:

101.50.101.50 > Primary DNS

101.50.101.51 > Secondary DNS

2. Using the less Command

The less command function is similar to the Linux cat command. The difference is that the cat command reads a small file’s data and displays its output; whereas the less command is used to read extensive file data and display its output page by page.

We can also utilize this utility to find the DNS Server IP Address by running the command mentioned below:

sudo less /etc/resolv.conf


This address 127.0.0.53 is a loopback address used to send requests to the DNS server 101.50.101.50.

3. Using grep Command

Linux grep command is used to search and match similar patterns in a file and display them. Run the given command to find out the DNS Server IP Address using this command-line utility:su

sudo grep "nameserver" /etc/resolv.conf

2. Find the DNS Server IP Address Through nmcli Command

The NetworkManager Command-line Interface (nmcli) is the Linux command-line utility used to handle network-related issues and configuration.

Execute the given command to let it display the DNS Server IP Address on the Ubuntu system:

sudo nmcli dev show | grep 'IP4.DNS'

3. Find DNS Server IP Address Through dig Command

The Domain Information Groper (dig) command is used to retrieve information regarding the DNS name server. It looks out for the specific query name server given by the user and prints the output.

dig linuxhint.com

How to Find DNS Server IP Address Using Graphical User Interface

Not only using the CLI but there’s also another way to find the DNS Server IP address i.e., GUI.

Step 1: Move to the Show Applications icons located at the bottom left corner of the Ubuntu 22.04 screen and click it:

Step 2: Click on Settings from the displayed screen; if you don’t find it, type Settings in the search box:

Step 3: Move to the Network from the left panel and select it:

Step 4: In the Network screen, move to the gear icon in Wired section and select it:

Step 5: The displayed window will show the networking details including the DNS server addresses:

101.40.101.50 > Primary

101.50.101.51 > Secondary

Conclusion

The DNS maps the IP addresses whenever the user sends a domain request to the server. It works as a phonebook on the internet that matches the correct IP address and returns it to the user. This guide has mentioned multiple methods to find the DNS server IP address on a Linux system i.e., through Command-line Interface and Graphical User Interface. By using the terminal method, we have found numerous command-line tools to get the DNS server IP address. You can use the one that is most suitable for you.

About the author

Syeda Wardah Batool

I am a Software Engineer Graduate and Self Motivated Linux writer. I also love to read latest Linux books. Moreover, in my free time, i love to read books on Personal development.