dig command using --DNS

A command output explained:

dig www.baidu.com

 

<!--?xml version="1.0" encoding="UTF-8" standalone="no"?-->
# dig www.baidu.com
 
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6_7.4 <<>> www.baidu.com
;; global options: +cmd
 
#The above part is controlled by the +[no]cmd option, which displays information such as printing the version of the dig command
 
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54443
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 5, ADDITIONAL: 5
 
#The above part +[no]comment option control, display the overall situation of the answer
 
;; QUESTION SECTION:
;www.baidu.com.                 IN      A
 
#The above part +[no]question option control, display query, default query A record
 
;; ANSWER SECTION:
www.baidu.com.          15      IN      CNAME   www.a.shifen.com.
www.a.shifen.com. 71 IN A 115.239.211.112 (Baidu IP)
www.a.shifen.com. 71 IN A 115.239.210.27 (Baidu IP)
 
#The above part +[no]answer option control, print the answer, the main record of the domain name
 
;; AUTHORITY SECTION:
a.shifen.com. 369 IN NS ns1.a.shifen.com.
a.shifen.com. 369 IN NS ns3.a.shifen.com.
a.shifen.com. 369 IN NS ns5.a.shifen.com.
a.shifen.com. 369 IN NS ns2.a.shifen.com.
a.shifen.com. 369 IN NS ns4.a.shifen.com.
 
#The above part +[no]authority option controls, showing which authoritative servers provide information for the response
 
;; ADDITIONAL SECTION:
ns1.a.shifen.com.       369     IN      A       61.135.165.224
ns2.a.shifen.com.       369     IN      A       180.149.133.241
ns3.a.shifen.com.       369     IN      A       61.135.162.215
ns4.a.shifen.com.       369     IN      A       115.239.210.176
ns5.a.shifen.com.       369     IN      A       119.75.222.17
 
#以上部分+[no]additional选项控制,显示附加信息,主要是权威服务器IP
 
;; Query time: 0 msec 
;; SERVER: 10.202.72.118#53(10.202.72.118)
;; WHEN: Tue Jan  5 10:38:01 2016
;; MSG SIZE  rcvd: 260
 
#以上部分+[no]stats选项控制,显示请求过程的相关信息

 

二 常用方式:

1)获取域名对应IP的精简答案
dig www.baidu.com +short
 
2)查看各种记录情况
dig www.baidu.com CNAME 
 
3)结合效果
dig www.baidu.com CNAME  +short
 
4)查询大量域名的ip
dig -f /tmp/domain
 
5)追踪DNS解析
dig www.baidu.com +trace
 
6)查看ptr记录

dig -x 115.239.211.112

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326799352&siteId=291194637