Dig Command (Domain Information Groper) to Query DNS
Various Linux Dig Commands (Domain Information Groper) to Query DNS
Dig command stands for (Domain Information Groper) is a network administration command-line tool for querying Domain Name System (DNS) name servers. It is useful for verifying and troubleshooting DNS problems. In this article we will, learn some useful Dig commands.
Using dig command without any options
The below command will show DNS query status in Verbosely.
[root@linuxhelp ~]# dig linuxhelp.com
< < > > DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6 < < > > linuxhelp.com
global options: +cmd
Got answer:
-> > HEADER<
To Record using +short options
To cut down the output is to use the +short option.
[root@linuxhelp ~]# dig linuxhelp.com +short
192.155.206.82
To query MX Record for Domain
Run the following command to query Main Exchange Mx Records.
[root@linuxhelp ~]# dig linuxhelp.com MX
< < > > DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6 < < > > linuxhelp.com MX
global options: +cmd
Got answer:
-> > HEADER<
To Query SOA Record for Domain
Run the following command to query SOA (Start of Authority) Records.
[root@linuxhelp ~]# dig linuxhelp.com SOA
< < > > DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6 < < > > linuxhelp.com SOA
global options: +cmd
Got answer:
-> > HEADER<
To Query TTL Record for Domain
Run the following command to query Time To Live (TTL) Records.
[root@linuxhelp ~]# dig linuxhelp.com TTL
< < > > DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6 < < > > linuxhelp.com TTL
global options: +cmd
Got answer:
-> > HEADER< > HEADER<
To Query only answer section
The below command to query answer section alone.
[root@linuxhelp ~]# dig linuxhelp.com +nocomments +noquestion +noauthority +noadditional +nostats
< < > > DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6 < < > > linuxhelp.com +nocomments +noquestion +noauthority +noadditional +nostats
global options: +cmd
linuxhelp.com. 14399 IN A 192.155.206.82
To Query ALL DNS Records Types
The below command will perform query the ALL DNS Records.
[root@linuxhelp ~]# dig linuxhelp.com ANY +noall +answer
< < > > DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6 < < > > linuxhelp.com ANY +noall +answer
global options: +cmd
linuxhelp.com. 21599 IN SOA ns1.yookar.com. peter.netaxis.in. 2016030803 3600 7200 1209600 86400
linuxhelp.com. 21599 IN NS ns1.yookar.com.
linuxhelp.com. 21599 IN NS ns2.yookar.com.
linuxhelp.com. 21599 IN NS ns3.yookar.com.
linuxhelp.com. 21599 IN NS ns4.yookar.com.
linuxhelp.com. 14399 IN A 192.155.206.82
linuxhelp.com. 14399 IN MX 0 linuxhelp.com.
To Query DNS Reverse Look-up
The following command query the DNS Reverse Look-up
[root@linuxhelp ~]# dig -x 192.155.206.82 +short
52.ce.9bc0.ip4.static.sl-reverse.com.
To Query Multiple DNS Records
The following command to query multiple website’ s DNS specific query viz. MX, NS etc. records.
[root@linuxhelp ~]# dig linuxhelp.com mx +noall +answer google.com ns +noall +answer
< < > > DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6 < < > > linuxhelp.com mx +noall +answer google.com ns +noall +answer
global options: +cmd
linuxhelp.com. 14366 IN MX 0 linuxhelp.com.
google.com. 21599 IN NS ns3.google.com.
google.com. 21599 IN NS ns2.google.com.
google.com. 21599 IN NS ns1.google.com.
google.com. 21599 IN NS ns4.google.com.
Using &ndash f with Dig command
It is the another method to query the multiple DNS records.
First thing you should create one text file and enter your multiple domain into that text file and then use with dig command by following method.
[root@linuxhelp ~]# dig -f dig.txt
< < > > DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6 < < > > facebook.com
global options: +cmd
Got answer:
-> > HEADER< > DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6 < < > > google.com
Got answer:
-> > HEADER< > DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6 < < > > twitter.com
Got answer:
-> > HEADER<
[root@linuxhelp ~]# dig -f dig.txt +noall +answer
facebook.com. 35 IN A 173.252.120.68
google.com. 299 IN A 216.58.197.78 l
twitter.com. 16 IN A 199.59.148.82
twitter.com. 16 IN A 199.59.150.7
twitter.com. 16 IN A 199.59.149.198
twitter.com. 16 IN A 199.59.149.230
Command to the check the version of Dig tool
[root@linuxhelp ~]# dig -v
DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6
Comments ( 0 )
No comments available