Linux Command Line learning-dig (DNS finder)

Source: Internet
Author: User
Tags domain name server domain server

In web development. Always familiar with the HTTP protocol. One of the first processes to go through before initiating an HTTP start is DNS resolution. Simply say is how the domain name finally resolves to the actual serverip process.

A powerful tool in the study of DNS parsing and troubleshooting DNS resolution classes is dig.

And he has a relatively traditional command nslookup, just dig as a newer command, its powerful and concise customizable output is also made operational by its developers.

Instance 1 (Access server local dnsserver query root domain server): ~#: Dig

; <<>> DiG 9.3.6-p1-redhat-9.3.6-20.p1.el5_8.6 <<>>
;; Global Options:printcmd
;; Got Answer:
;; ->>header<<-opcode:query, Status:noerror, id:39027
;; Flags:qr Rd RA; Query:1, Answer:13, authority:0, additional:13


;; QUESTION section:
;. Inch Ns

;; ANSWER section:
. 85715 Inch Ns A.root-servers.net.
. 85715 Inch Ns L.root-servers.net.
. 85715 Inch Ns F.root-servers.net.
. 85715 Inch Ns D.root-servers.net.
. 85715 Inch Ns E.root-servers.net.
. 85715 Inch Ns B.root-servers.net.
. 85715 Inch Ns C.root-servers.net.
. 85715 Inch Ns M.root-servers.net.
. 85715 Inch Ns K.root-servers.net.
. 85715 Inch Ns I.root-servers.net.
. 85715 Inch Ns J.root-servers.net.
. 85715 Inch Ns H.root-servers.net.
. 85715 Inch Ns G.root-servers.net.



Example 2 (Baidu Home DNS resolution): Dig www.baidu.com

; <<>> DiG 9.3.6-p1-redhat-9.3.6-20.p1.el5_8.6 <<>> www.baidu.com
;; Global Options:printcmd
;; Got Answer:
;; ->>header<<-opcode:query, Status:noerror, id:15372
;; Flags:qr Rd RA; Query:1, Answer:3, authority:0, additional:0

;; QUESTION section:
; www.baidu.com. InchA

;; ANSWER section:
Www.baidu.com. 641Inch CNAMEWww.a.shifen.com.
Www.a.shifen.com. 110Inch A 180.97.33.107
Www.a.shifen.com. 110Inch A 180.97.33.108

;; Query Time:1 msec
;; server:192.168.100.52#53 (192.168.100.52)
;; when:wed 13 22:33:59 2014
;; MSG SIZE rcvd:90


Example 3 (make use of Google domain name server to resolve Baidu homepage); Dig @8.8.8.8 www.baidu.com

; <<>> DiG 9.3.6-p1-redhat-9.3.6-20.p1.el5_8.6 <<>> @8.8.8.8 www.baidu.com
; (1 server found)
;; Global Options:printcmd
;; Got Answer:
;; ->>header<<-opcode:query, Status:noerror, id:44033
;; Flags:qr Rd RA; Query:1, Answer:2, authority:0, additional:0

;; QUESTION section:
; www.baidu.com. InchA


;; ANSWER section:
Www.baidu.com. 557Inch CNAMEWww.a.shifen.com.
Www.a.shifen.com. 299Inch A 180.76.3.151


;; Query time:615 msec
;; server:8.8.8.8#53 (8.8.8.8)
;; when:wed 13 22:36:36 2014
;; MSG SIZE rcvd:74


Example 4 (using the +trace option to view the process from the root domain server to finally resolving to IP): Dig www.baidu.com +trace

. 84899 Inch Ns F.root-servers.net.
. 84899 Inch Ns D.root-servers.net.
. 84899 Inch Ns E.root-servers.net.
. 84899 Inch Ns B.root-servers.net.
. 84899 Inch Ns C.root-servers.net.
. 84899 Inch Ns M.root-servers.net.
. 84899 Inch Ns K.root-servers.net.
. 84899 Inch Ns I.root-servers.net.
. 84899 Inch Ns J.root-servers.net.
. 84899 Inch Ns H.root-servers.net.
. 84899 Inch Ns G.root-servers.net.
. 84899 Inch Ns A.root-servers.net.
. 84899 Inch Ns L.root-servers.net.
;; Received 509 bytes from 192.168.100.52#53 (192.168.100.52) in 1 ms

Description: Get several root name servers from local dnsserver


Com. 172800 Inch Ns A.gtld-servers.net.
Com. 172800 Inch Ns E.gtld-servers.net.
Com. 172800 Inch Ns H.gtld-servers.net.
Com. 172800 Inch Ns J.gtld-servers.net.
Com. 172800 Inch Ns I.gtld-servers.net.
Com. 172800 Inch Ns K.gtld-servers.net.
Com. 172800 Inch Ns B.gtld-servers.net.
Com. 172800 Inch Ns M.gtld-servers.net.
Com. 172800 Inch Ns F.gtld-servers.net.
Com. 172800 Inch Ns G.gtld-servers.net.
Com. 172800 Inch Ns C.gtld-servers.net.
Com. 172800 Inch Ns D.gtld-servers.net.
Com. 172800 Inch Ns L.gtld-servers.net.
;; Received 503 bytes from 192.5.5.241#53 (f.root-servers.net) in
Description: Select f.root-servers.net root domain server to query the COM domain name server

Baidu.com. 172800Inch Ns Dns.baidu.com.
Baidu.com. 172800Inch Ns Ns2.baidu.com.
Baidu.com. 172800Inch Ns Ns3.baidu.com.
Baidu.com. 172800Inch Ns Ns4.baidu.com.
Baidu.com. 172800Inch Ns Ns7.baidu.com.
;; Received 201 bytes from 192.5.6.30#53 (a.gtld-servers.net) in MS
Description: Select a.gtld-servers.net COM domain name server to resolve baidu.com domain name server

Www.baidu.com. 1200Inch CNAMEWww.a.shifen.com.
A.shifen.com. 1200Inch Ns Ns3.a.shifen.com.
A.shifen.com. 1200Inch Ns Ns5.a.shifen.com.
A.shifen.com. 1200Inch Ns Ns1.a.shifen.com.
A.shifen.com. 1200Inch Ns Ns4.a.shifen.com.
A.shifen.com. 1200Inch Ns Ns2.a.shifen.com.
;; Received 228 bytes from 202.108.22.220#53 (dns.baidu.com) in 206 ms

Description: dns.baidu.com domain name server resolves to www.baidu.com as an alias for www.a.shifen.com by selecting Access.


So we dig down www.a.shifen.com.

[Email protected] jakquan]# dig www.a.shifen.com +short
180.97.33.108
180.97.33.107

Linux Command Line learning-dig (DNS finder)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.