Top 12 Examples of Linux dig Command

Dig (domain information groper) command is used to get information about the domain name server (dns). This command is very popular among network administrators and Linux users because of its vast functionality and ease of use.  This tool is readily available for Linux (Unix) or Macintosh OS X operating systems. Here I am listing examples that will help you better understand the capability and functionality of the dig command.

(1) Basic query to extract information from DNS servers


(2) To resolve only the IP of the test URL

#dig +short

(3) To extract information of DNS MX records of test URL

Mail exchanger (MX) records of a domain name tell the routing of email with SMTP

#dig MX

(4) To extract the information of IP by doing a reverse lookup

#dig -x

(5) Use IPv4 or IPv6 transport

#dig -4

#dig -6

(6) To print all options available

#dig -h

(7) To see all DNS records available with the test domain

Results contain different records, including A, AAAA, TXT, MX, and NS.

#dig any

(8) To hide all the output of the executed command

Basically, this command is used to control the print output.

#dig +noall

(9) To print only stats such as query time, server information, message size, etc. of the test domain

#dig +noall +stats

(10) To print only the resolved IP of the test domain

#dig +noall +answer

(11) To extract SOA records of the test domain

A start of authority (SOA) record signifies the information stored in a DNS zone about that zone and about other DNS records

#dig SOA

(12) Query MX type of records from the specific name server

#dig @ MX


We have seen the top 12 examples of Linux dig commands which helped you in understanding the concept of DNS servers.

Subscribe us to receive more such articles updates in your email.

If you have any questions, feel free to ask in the comments section below. Nothing gives me greater joy than helping my readers!

Disclaimer: This tutorial is for educational purpose only. Individual is solely responsible for any illegal act.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *