Common Linux Commands - Learning Notes 3

Keywords: DNS

Di DNS (Domain Name System) Query Tool

$ dig www.baidu.com

; <<>> DiG 9.9.4-RedHat-9.9.4-74.el7_6.2 <<>> www.baidu.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53570
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.baidu.com.			IN	A

;; ANSWER SECTION:
www.baidu.com.		1094	IN	CNAME	www.a.shifen.com.
www.a.shifen.com.	51	IN	A	112.80.248.76
www.a.shifen.com.	51	IN	A	112.80.248.75

;; Query time: 5 msec
;; SERVER: 210.22.70.3#53(210.22.70.3)
;; WHEN: Sat Aug 17 20:47:46 CST 2019
;; MSG SIZE  rcvd: 101

The first paragraph is about query parameters and statistics.

; <<>> DiG 9.9.4-RedHat-9.9.4-74.el7_6.2 <<>> www.baidu.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53570
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1

The second paragraph is the query content.

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.baidu.com.			IN	A

The above results indicate that query domain name www.baidu.com A record, A is the abbreviation of address.

The third paragraph is the DNS server's reply

;; ANSWER SECTION:
www.baidu.com.		1094	IN	CNAME	www.a.shifen.com.
www.a.shifen.com.	51	IN	A	112.80.248.76
www.a.shifen.com.	51	IN	A	112.80.248.75

The results above show that www.baidu.com is an alias for www.a.shifen.com, CNAME: Canonical Name, and returns another domain name, that is, the domain name currently queried is a jump of another domain name. Www.a.shifen.com has two A records, i.e. two IP addresses. 51 is the TTL value (abbreviated as Time to live), which indicates the cache time, i.e. no re-query within 51 seconds.

The fourth section is some transmission information of DNS server.

;; Query time: 5 msec
;; SERVER: 210.22.70.3#53(210.22.70.3)
;; WHEN: Sat Aug 17 20:47:46 CST 2019
;; MSG SIZE  rcvd: 101

The results show that the DNS server is 210.22.70.3, the query port is 53 (the default port of the DNS server), and the response length is 101 bytes.

Other uses

# + The short parameter simplifies the contents returned by dig
$ dig +short www.baidu.com
www.a.shifen.com.
112.80.248.76
112.80.248.75

Reference from http://www.ruanyifeng.com/blog/2016/06/dns.html

Posted by Anim9or on Wed, 02 Oct 2019 13:33:18 -0700