Unix/Linux Guru and FOSS supporter

How to Install Dig in Linux with Command Line Examples

What is Dig?

Dig (Domain Information Groper) is a command-line utility that performs DNS lookup by querying name servers and displaying the result to you. The Dig command is another powerful tool similar to nslookup for diagnosing DNS-related problems.

In this tutorial, we’ll see all the primary uses of the dig command with practical examples in the Linux operating system.

Install Dig on system

apt-get install dnsutils

yum install bind-utils

Verify Install
dig -v

Command Syntax

Before start command execute, let’s see how Dig command works. The Dig command syntax used as below:

dig server name type

Where server represents Name or IP address of the name server to query. It can be an IPv4 address or an IPv6 address in colon-delimited notation. The dig command sent queries to the /etc/resolv.conf file and the name servers listed there. The reply from the name server that responds is displayed.
The Name represents the server’s DNS to query & the Type indicates what Type of query is required, such as A, MX, SIG, etc.

Now let’s see some practical examples with dig command

Basic Command and Output (DNS Lookup)

this is very basic command line parameters to see dns address information.

The result ANSWER SECTION: contains the preliminary information you have requested. You can ignore other parts of the output which have additional details about the query you made. Generally, dig looks for the “A” record of the domain specified, but you can specify other records also. The MX or Mail exchange record tells mail servers how to route the email for the domain. Likewise, TTL, SOA, etc.

MX Record Lookup.

dig mx

Check Short & Details information.

dig +short
dig +noall +answer

NS Record Lookup.

dig ns

Lookup SOA record.

dig ns

Reverse DNS(rDNS) Lookup.

dig -x

Lookup TTL Record.

dig ttl

Lookup ANY DNS Records.

dig any
dig any +noall +answer


In this tutorial, we tried to find out the maximum usage of dig command which may help you search (DNS) Domain Name Service-related information. Share your thoughts through the comment box. you can follow my other posts.


Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook