To check dig for multiple domains
[root@localhost ~]# vim digcheck
google.com
yahoo.com
gmail.com
linuxmadeeasy.in
puppethub.in
youtube.com
[root@localhost ~]# dig -f digcheck +noall +answer
google.com. 258 IN A 216.58.199.142
yahoo.com. 1459 IN A 98.139.183.24
yahoo.com. 1459 IN A 206.190.36.45
yahoo.com. 1459 IN A 98.138.253.109
gmail.com. 300 IN A 216.58.199.165
linuxmadeeasy.in. 600 IN A 50.63.202.2
puppethub.in. 600 IN A 50.63.202.59
youtube.com. 300 IN A 216.58.199.142
————————————————–
+nocomments – Turn off the comment lines
+noauthority – Turn off the authority section
+noadditional – Turn off the additional section
+nostats – Turn off the stats section
+noanswer – Turn off the answer section (Of course, you wouldn’t want to turn off the answer section)
[root@localhost ~]# dig yahoo.com
; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.3 <<>> yahoo.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 13746
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;yahoo.com. IN A
;; ANSWER SECTION:
yahoo.com. 773 IN A 206.190.36.45
yahoo.com. 773 IN A 98.139.183.24
yahoo.com. 773 IN A 98.138.253.109
;; Query time: 1 msec
;; SERVER: 192.168.122.1#53(192.168.122.1)
;; WHEN: Sun Aug 21 11:42:44 IST 2016
;; MSG SIZE rcvd: 75
Header: This displays the dig command version number, the global options used by the dig command, and few additional header information.
QUESTION SECTION: This displays the question it asked the DNS. i.e This is your input. Since we said ‘dig redhat.com’, and the default type dig command uses is A record, it indicates in this section that we asked for the A record of the redhat.com website
ANSWER SECTION: This displays the answer it receives from the DNS. i.e This is your output. This displays the A record of redhat.com
AUTHORITY SECTION: This displays the DNS name server that has the authority to respond to this query. Basically this displays available name servers of redhat.com
ADDITIONAL SECTION: This displays the ip address of the name servers listed in the
AUTHORITY SECTION
Stats section at the bottom displays few dig command statistics including how much time it took to execute this query
[root@localhost ~]# dig yahoo.com +nocomments +noquestion +noauthority +noadditional +nostats
; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.3 <<>> yahoo.com +nocomments +noquestion +noauthority +noadditional +nostats
;; global options: +cmd
yahoo.com. 1039 IN A 98.139.183.24
yahoo.com. 1039 IN A 98.138.253.109
yahoo.com. 1039 IN A 206.190.36.45
[root@localhost ~]# dig +short yahoo.com
98.138.253.109
206.190.36.45
98.139.183.24
[root@localhost ~]# dig yahoo.com A +short
98.138.253.109
206.190.36.45
98.139.183.24
[root@localhost ~]# dig yahoo.com AAAA +short
2001:4998:44:204::a7
2001:4998:c:a06::2:4008
2001:4998:58:c02::a9
[root@localhost ~]# dig yahoo.com MX +short
1 mta7.am0.yahoodns.net.
1 mta5.am0.yahoodns.net.
1 mta6.am0.yahoodns.net.
[root@localhost ~]# dig yahoo.com TXT +short
“v=spf1 redirect=_spf.mail.yahoo.com”
[root@localhost ~]# dig yahoo.com NS +short
ns2.yahoo.com.
ns6.yahoo.com.
ns4.yahoo.com.
ns1.yahoo.com.
ns3.yahoo.com.
ns5.yahoo.com.
[root@localhost ~]# dig yahoo.com SOA +short
ns1.yahoo.com. hostmaster.yahoo-inc.com. 2016082006 3600 300 1814400 600
[root@localhost ~]# dig yahoo.com ANY +noall +answer
; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.3 <<>> yahoo.com ANY +noall +answer
;; global options: +cmd
yahoo.com. 1141 IN TXT “v=spf1 redirect=_spf.mail.yahoo.com”
yahoo.com. 1141 IN MX 1 mta5.am0.yahoodns.net.
yahoo.com. 1141 IN MX 1 mta6.am0.yahoodns.net.
yahoo.com. 1141 IN MX 1 mta7.am0.yahoodns.net.
yahoo.com. 1141 IN SOA ns1.yahoo.com. hostmaster.yahoo-inc.com. 2016082006 3600 300 1814400 600
yahoo.com. 174 IN AAAA 2001:4998:58:c02::a9
yahoo.com. 174 IN AAAA 2001:4998:c:a06::2:4008
yahoo.com. 174 IN AAAA 2001:4998:44:204::a7
yahoo.com. 367 IN A 98.138.253.109
yahoo.com. 367 IN A 98.139.183.24
yahoo.com. 367 IN A 206.190.36.45
yahoo.com. 172141 IN NS ns6.yahoo.com.
yahoo.com. 172141 IN NS ns4.yahoo.com.
yahoo.com. 172141 IN NS ns1.yahoo.com.
yahoo.com. 172141 IN NS ns5.yahoo.com.
yahoo.com. 172141 IN NS ns2.yahoo.com.
yahoo.com. 172141 IN NS ns3.yahoo.com.
[root@localhost ~]# dig +nocmd yahoo.com any +multiline +noall +answer
yahoo.com. 1800 IN TXT “v=spf1 redirect=_spf.mail.yahoo.com”
yahoo.com. 1800 IN MX 1 mta5.am0.yahoodns.net.
yahoo.com. 1800 IN MX 1 mta6.am0.yahoodns.net.
yahoo.com. 1800 IN MX 1 mta7.am0.yahoodns.net.
yahoo.com. 1800 IN SOA ns1.yahoo.com. hostmaster.yahoo-inc.com. (
2016082006 ; serial
3600 ; refresh (1 hour)
300 ; retry (5 minutes)
1814400 ; expire (3 weeks)
600 ; minimum (10 minutes)
)
yahoo.com. 300 IN AAAA 2001:4998:44:204::a7
yahoo.com. 300 IN AAAA 2001:4998:58:c02::a9
yahoo.com. 300 IN AAAA 2001:4998:c:a06::2:4008
yahoo.com. 1471 IN A 98.139.183.24
yahoo.com. 1471 IN A 206.190.36.45
yahoo.com. 1471 IN A 98.138.253.109
yahoo.com. 172800 IN NS ns4.yahoo.com.
yahoo.com. 172800 IN NS ns1.yahoo.com.
yahoo.com. 172800 IN NS ns3.yahoo.com.
yahoo.com. 172800 IN NS ns2.yahoo.com.
yahoo.com. 172800 IN NS ns5.yahoo.com.
yahoo.com. 172800 IN NS ns6.yahoo.com.
[root@localhost ~]# dig yahoo.com NS
; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.3 <<>> yahoo.com NS
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51367
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;yahoo.com. IN NS
;; ANSWER SECTION:
yahoo.com. 172320 IN NS ns6.yahoo.com.
yahoo.com. 172320 IN NS ns5.yahoo.com.
yahoo.com. 172320 IN NS ns2.yahoo.com.
yahoo.com. 172320 IN NS ns1.yahoo.com.
yahoo.com. 172320 IN NS ns4.yahoo.com.
yahoo.com. 172320 IN NS ns3.yahoo.com.
;; Query time: 41 msec
;; SERVER: 192.168.122.1#53(192.168.122.1)
;; WHEN: Sun Aug 21 11:46:32 IST 2016
;; MSG SIZE rcvd: 146
[root@localhost ~]# dig yahoo.com A
; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.3 <<>> yahoo.com A
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 13948
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;yahoo.com. IN A
;; ANSWER SECTION:
yahoo.com. 476 IN A 98.139.183.24
yahoo.com. 476 IN A 98.138.253.109
yahoo.com. 476 IN A 206.190.36.45
;; Query time: 1 msec
;; SERVER: 192.168.122.1#53(192.168.122.1)
;; WHEN: Sun Aug 21 11:47:42 IST 2016
;; MSG SIZE rcvd: 75
[root@localhost ~]# dig yahoo.com AAAA
; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.3 <<>> yahoo.com AAAA
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 42666
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;yahoo.com. IN AAAA
;; ANSWER SECTION:
yahoo.com. 274 IN AAAA 2001:4998:c:a06::2:4008
yahoo.com. 274 IN AAAA 2001:4998:44:204::a7
yahoo.com. 274 IN AAAA 2001:4998:58:c02::a9
;; Query time: 39 msec
;; SERVER: 192.168.122.1#53(192.168.122.1)
;; WHEN: Sun Aug 21 11:47:50 IST 2016
;; MSG SIZE rcvd: 122
[root@localhost ~]# dig yahoo.com MX
; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.3 <<>> yahoo.com MX
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50635
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;yahoo.com. IN MX
;; ANSWER SECTION:
yahoo.com. 1470 IN MX 1 mta6.am0.yahoodns.net.
yahoo.com. 1470 IN MX 1 mta7.am0.yahoodns.net.
yahoo.com. 1470 IN MX 1 mta5.am0.yahoodns.net.
;; Query time: 59 msec
;; SERVER: 192.168.122.1#53(192.168.122.1)
;; WHEN: Sun Aug 21 11:44:19 IST 2016
;; MSG SIZE rcvd: 117
[root@localhost ~]#
dig -x 98.138.253.109 +short
ir1.fp.vip.ne1.yahoo.com.[root@localhost ~]#
dig -x 98.138.253.109
; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.3 <<>> -x 98.138.253.109
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 36616
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;109.253.138.98.in-addr.arpa. IN PTR
;; ANSWER SECTION:
109.253.138.98.in-addr.arpa. 1767 IN PTR ir1.fp.vip.ne1.yahoo.com.
;; Query time: 1 msec
;; SERVER: 192.168.122.1#53(192.168.122.1)
;; WHEN: Sun Aug 21 13:06:14 IST 2016
;; MSG SIZE rcvd: 83