Linux Command Line Learning-dig (DNS queryer)

Source: Internet
Author: User

Linux Command Line Learning-dig (DNS queryer)

In web development, the http protocol is always familiar, and the first process to be experienced before initiating an http request is DNS resolution. Simply put, it is how the domain name is finally resolved to the actual Server ip address.

A powerful tool for studying DNS resolution and troubleshooting DNS faults is dig. There is a relatively traditional command nslookup corresponding to it. However, dig, as an updated command, has powerful, concise, and customizable output that can be used by O & M engineers.

Instance 1 (access the server's local DNSserver to query the Root Domain Name 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:
;. IN NS

; Answer section:
. 85715 in ns a.root-servers.net.
. 85715 in ns l.root-servers.net.
. 85715 in ns f.root-servers.net.
. 85715 in ns d.root-servers.net.
. 85715 in ns e.root-servers.net.
. 85715 in ns B .root-servers.net.
. 85715 in ns c.root-servers.net.
. 85715 in ns m.root-servers.net.
. 85715 in ns k.root-servers.net.
. 85715 in ns I .root-servers.net.
. 85715 in ns j.root-servers.net.
. 85715 in ns h.root-servers.net.
. 85715 in ns g.root-servers.net.

Instance 2 (Baidu homepage 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. INA

; Answer section:
Www.baidu.com. 641IN CNAMEwww.a.shifen.com.
Www.a.shifen.com. 110IN A 180.97.33.107
Www.a.shifen.com. 110IN A 180.97.33.108

; Query time: 1 msec
; SERVER: 192.168.100.52 #53 (192.168.100.52)
; WHEN: Wed Aug 13 22:33:59 2014
; Msg size rcvd: 90

Instance 3 (the google Domain Name Server is used to resolve the Baidu homepage); dig @ 8.8.8.8 www.baidu.com

; & Lt; & gt; DiG 9.3.6-P1-RedHat-9.3.6-20.P1.el5_8.6 & lt; & gt; @ 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. INA


; Answer section:
Www.baidu.com. 557IN CNAMEwww.a.shifen.com.
Www.a.shifen.com. 299IN A 180.76.3.151


; Query time: 615 msec
; SERVER: 8.8.8.8 #53 (8.8.8.8)
; WHEN: Wed Aug 13 22:36:36 2014
; Msg size rcvd: 74

Instance 4 (use the + trace option to view the process from the root domain name server to the final resolution to the ip address): dig www.baidu.com + trace

. 84899 in ns f.root-servers.net.
. 84899 in ns d.root-servers.net.
. 84899 in ns e.root-servers.net.
. 84899 in ns B .root-servers.net.
. 84899 in ns c.root-servers.net.
. 84899 in ns m.root-servers.net.
. 84899 in ns k.root-servers.net.
. 84899 in ns I .root-servers.net.
. 84899 in ns j.root-servers.net.
. 84899 in ns h.root-servers.net.
. 84899 in ns g.root-servers.net.
. 84899 in ns a.root-servers.net.
. 84899 in ns l.root-servers.net.
; Received 509 bytes from 192.168.100.52 #53 (192.168.100.52) in 1 MS

Note: Several root domain name servers are obtained from the local DNS server.


Com. 172800 in ns a.gtld-servers.net.
Com. 172800 in ns e.gtld-servers.net.
Com. 172800 in ns h.gtld-servers.net.
Com. 172800 in ns j.gtld-servers.net.
Com. 172800 in ns I .gtld-servers.net.
Com. 172800 in ns k.gtld-servers.net.
Com. 172800 in ns B .gtld-servers.net.
Com. 172800 in ns m.gtld-servers.net.
Com. 172800 in ns f.gtld-servers.net.
Com. 172800 in ns g.gtld-servers.net.
Com. 172800 in ns c.gtld-servers.net.
Com. 172800 in ns d.gtld-servers.net.
Com. 172800 in ns l.gtld-servers.net.
; Received 503 bytes from 192.5.5.241 #53 (f.root-servers.net) in 39 MS
(Select f.root-servers.net Root Domain Name Server Query com Domain Name Server)

Baidu.com. 172800IN NS dns.baidu.com.
Baidu.com. 172800IN NS ns2.baidu.com.
Baidu.com. 172800IN NS ns3.baidu.com.
Baidu.com. 172800IN NS ns4.baidu.com.
Baidu.com. 172800IN NS ns7.baidu.com.
; Received 201 bytes from 192.5.6.30 #53 (a.gtld-servers.net) in 360 MS
(Select the.gtld-servers.net of com Domain Name Server Resolution baidu.com Domain Name Server)

Www.baidu.com. Alibaba in CNAMEwww.a.shifen.com.
A.shifen.com. logs in NS ns3.a.shifen.com.
A.shifen.com. logs in NS ns5.a.shifen.com.
A.shifen.com. logs in NS ns1.a.shifen.com.
A.shifen.com. logs in NS ns4.a.shifen.com.
A.shifen.com. logs in NS ns2.a.shifen.com.
; Received 228 bytes from 202.108.22.220 #53 (dns.baidu.com) in 206 MS

Note: by choosing to access the dns.baidu.com Domain Name Server to resolve to www.baidu.com as the alias of www.a.shifen.com;

So let's go to www.a.shifen.com under dig.

[Root @ local200-65 JakQuan] # dig www.a.shifen.com + short
180.97.33.108
180.97.33.107

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.