The dig command is a common domain name query tool that you can use to test whether your domain Name system is working properly.
Grammar:
Dig (option) (parameter)
Options:
@< server address;: Specifies the domain name server for domain name resolution;
-B: When the host has multiple IP addresses, specify which IP address to use to send Domain name query requests to the domain name server;
-f< file name;: Specifies that the dig is run as a batch, and the specified file holds the DNS task information that requires a batch query;
-P: Specifies the port number used by the domain name server;
-t< type;: Specifies the type of DNS data to query;
-X: Perform reverse domain name query;
-4: Use IPV4;
-6: Use IPV6;
-H: Displays instruction help information.
Parameters:
Host: Specify to query the domain host;
Query type: Specifies the type of DNS query;
Query class: Specifies the class that queries DNS;
Query options: Specify query options.
Instance:
DNS parsing www.baidu.com whole process
[Email protected] ~]# Dig @8.8.8.8Www.baidu.com +Trace;<<>> DiG9.8.2rc1-redhat-9.8.2-0.37. rc1.el6 <<>> @8.8.8.8Www.baidu.com +Trace; (1server found);; Global options:+cmd. 203653In NS a.root-servers.net .203653In NS b.root-servers.net .203653In NS c.root-servers.net .203653In NS d.root-servers.net .203653In NS e.root-servers.net .203653In NS f.root-servers.net .203653In NS g.root-servers.net .203653In NS h.root-servers.net .203653In NS i.root-servers.net .203653In NS j.root-servers.net .203653In NS k.root-servers.net .203653In NS l.root-servers.net .203653In NS m.root-servers.net.;; Received228Bytes from8.8.8.8# -(8.8.8.8)inch 277mscom. 172800In NS j.gtld-servers.net.com.172800In NS k.gtld-servers.net.com.172800In NS c.gtld-servers.net.com.172800In NS e.gtld-servers.net.com.172800In NS i.gtld-servers.net.com.172800In NS h.gtld-servers.net.com.172800In NS l.gtld-servers.net.com.172800In NS b.gtld-servers.net.com.172800In NS f.gtld-servers.net.com.172800In NS a.gtld-servers.net.com.172800In NS m.gtld-servers.net.com.172800In NS d.gtld-servers.net.com.172800In NS g.gtld-servers.net.;; Received491Bytes from192.5.5.241# -(192.5.5.241)inch 1207msbaidu.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.;; Received201Bytes from192.48.79.30# -(192.48.79.30)inch 401mswww.baidu.com. -In CNAME www.a.shifen.com.a.shifen.com. -In NS ns5.a.shifen.com.a.shifen.com. -In NS ns2.a.shifen.com.a.shifen.com. -In NS ns1.a.shifen.com.a.shifen.com. -In NS ns3.a.shifen.com.a.shifen.com. -In NS ns4.a.shifen.com.;; Received228Bytes from61.135.165.235# -(61.135.165.235)inch AMs
DNS resolution Www.baidu.com
[[Email protected] ~]# dig www.baidu.com; <<>> DiG9.8.2rc1-redhat-9.8.2-0.37. rc1.el6 <<>>www.baidu.com; global options:+cmd;; Got answer:;; ->>header<<-Opcode:query, Status:noerror,ID:61953;; Flags:qr Rd RA; QUERY:1, ANSWER:3, authority:0, ADDITIONAL:0;; QUESTION section:;www.baidu.com. in A;; ANSWER SECTION:www.baidu.com. 573In CNAME www.a.shifen.com.www.a.shifen.com. 109In A220.181.112.244www.a.shifen.com.109In A220.181.111.188;; Query Time:1msec;; SERVER:218.30.19.40# -(218.30.19.40);; when:wed Dec + ,: $: $ .;; MSG SIZE RCVD: -
Dig Common domain Name query tool