How to Find DNS on Linux Command?

How to Find DNS on Linux Command?

In the vast realm of Linux commands, navigating the intricacies of networking is a crucial skill. Understanding how to find Domain Name System (DNS) information directly from the command line is particularly valuable. Whether you're troubleshooting connectivity issues or simply curious about the DNS configuration, this guide will walk you through the steps to find DNS details using Linux commands.

  1. Checking Current DNS Configuration:

    To begin, let's inspect the current DNS configuration on your Linux system. Open your terminal and use the following command:

    cat /etc/resolv.conf

    This command displays the DNS configuration file, revealing the IP addresses of the DNS servers your system is currently using.

  2. Using 'dig' Command:

    The dig command is a powerful tool for querying DNS servers. To retrieve DNS information for a specific domain, use the following syntax:


    Replace "" with the domain you want to query. This command provides detailed information, including the authoritative DNS server and various resource records associated with the domain.

  3. Querying DNS Records with 'nslookup':

    Another useful command for DNS queries is nslookup. To obtain information about a specific domain, execute the following command:


    Similar to dig, this command fetches information about the specified domain, such as its IP address and the corresponding authoritative DNS server.

  4. Verifying DNS Cache with 'nscd':

    The Name Service Cache Daemon (nscd) is responsible for caching DNS information. To check the DNS cache status, you can use the following command:

    nscd -g hosts

    This command provides insights into the current state of the DNS cache, including the number of cached entries and the cache hit rate.

Step-by-Step Instructions:

  1. Open your terminal.
  2. To check the current DNS configuration, use cat /etc/resolv.conf.
  3. Execute dig to retrieve detailed DNS information for a specific domain.
  4. Alternatively, use nslookup for similar DNS queries.
  5. For DNS cache verification, employ nscd -g hosts.

More Examples:

  1. Querying MX Records:

    To find the mail exchange (MX) records for a domain, use the following dig command:

    dig +short -t mx

    This command provides a concise list of mail servers associated with the specified domain.

  2. Checking DNS Server Response Time:

    Evaluate the response time of a DNS server using the dig command with the "+stats" option:

    dig +stats

    Look for the "Query time" in the output, indicating the time taken for the DNS server to respond.

Related Searches and Questions asked:

  • How to Configure Primary and Secondary DNS Server in Linux?
  • How to Create DNS Server in CentOS?
  • How to Find All DNS Servers in Linux?
  • How to Configure DNS Server in Linux Step by Step?
  • That's it for this topic, Hope this article is useful. Thanks for Visiting us.