Dig stands for (Domain Information Groper). Dig is a network administration command-line tool for querying Domain Name System (DNS) name servers. It is useful for verifying and troubleshooting DNS problems and also to perform DNS lookups and displays the answers that are returned from the name server that were queried. dig is part of the BIND domain name server software suite. dig command replaces older tool such as nslookup and the host. dig tool is available in major Linux distributions.

Install Dig on Linux


  • apt-get install dnsutils

CentOS 7

  • yum install bind-utils

Dig Syntax

In its simplest form, the syntax of the dig utility will look like this:

  • dig [server] [name] [type]

[server] – the IP address or hostname of the name server to query

If the server argument is the hostname then dig will resolve the hostname before proceeding with querying the name server.

It is optional and if you don’t provide a server argument then dig uses the name server listed in /etc/resolv.conf

[name] – the name of the resource record that is to be looked up

[type] – the type of query requested by dig. For example, it can be an A record, MX record, SOA record or any other types. By default dig performs a lookup for an A record if no type argument is specified.


Dig Commands Cheatsheet

Dig a Domain Name

  • dig yahoo.com


  1. Lines beginning with ; are comments not part of the information.
  2. The first line tell us the version of dig (9.11.5) command.
  3. Next, dig shows the header of the response it received from the DNS server
  4. Next comes the question section, which simply tells us the query, which in this case is a query for the “A” record of yahoo.com. The IN means this is an Internet lookup (in the Internet class).
  5. The answer section tells us that yahoo.com has the IP address
  6. Lastly there are some stats about the query. You can turn off these stats using the +nostats option.

Short Answers

  • dig yahoo.com +short

Detailed Answers

  • dig yahoo.com +noall +answer

Specifying Nameservers

  • dig @ yahoo.com

The following dig command sends the DNS query to Google’s name server( by using the @ option

Query All DNS Record Types

  • dig yahoo.com ANY

Search For Record Type

  • dig yahoo.com MX
  • dig yahoo.com NS
  • dig yahoo.com A
  • dig yahoo.com SOA

Trace DNS Path

  • dig yahoo.com +trace

Reverse DNS Lookup

  • dig +answer -x

Reverse DNS lookup lets you look up the domain and hostname associated with an IP address.

Batch Queries

  • dig -f domain_name.txt +short

provide dig with a list of domain names – one per line in a file

Custom Query

  • dig axfr @ cronos.htb

Those different domains in the output point to the same IP.