dig經常使用命令

Dig是域信息搜索器的簡稱(Domain Information Groper),使用dig命令能夠執行查詢域名相關的任務。css

###1. 理解dig的輸出結果java

$ dig chenrongrong.info 1 ; <<>> DiG 9.9.5-3ubuntu0.1-Ubuntu <<>> chenrongrong.info 2 ;; global options: +cmd 3 ;; Got answer: 4 ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 22752 5 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 1 7 ;; OPT PSEUDOSECTION: 8 ; EDNS: version: 0, flags:; udp: 4096 9 ;; QUESTION SECTION: 10 ;chenrongrong.info. IN A 11 ;; ANSWER SECTION: 12 chenrongrong.info. 600 IN A 103.245.222.133 13 ;; AUTHORITY SECTION: 14 chenrongrong.info. 600 IN NS f1g1ns2.dnspod.net. 15 chenrongrong.info. 600 IN NS f1g1ns1.dnspod.net. 16 ;; Query time: 183 msec 17 ;; SERVER: 127.0.1.1#53(127.0.1.1) 18 ;; WHEN: Thu Dec 25 16:04:51 CST 2014 19 ;; MSG SIZE rcvd: 116 

1~8: 顯示了dig的基本設置信息,e.g. java -versionubuntu

9-10: 顯示了查詢內容,這裏查詢的是域名chenrongrong.infoA記錄ruby

11-12: 顯示了查詢結果,域名chenrongrong.infoA記錄是103.245.222.133(A (Address) 記錄是用來指定主機名(或域名)對應的IP地址記)服務器

13-15: 受權信息,域名chenrongrong.info的NS(nameserver)是dnspod的域名服務器學習

16-19: 統計信息google

上述選項均可以經過對應選項選擇是否輸出,+[no]question,+[no]answer,+[no]authority,+[no]stat,固然+short更加簡潔spa

###2. 顯示特定的輸出結果.net

+[no]comments – Turn off the comment lines +[no]authority – Turn off the authority section +[no]additional – Turn off the additional section +[no]stats – Turn off the stats section +[no]answer – Turn off the answer section (Of course, you wouldn’t want to turn off the answer section) 

###3. 查詢MX記錄 MX(Mail Exchanger)記錄查詢:code

$  dig redhat.com  MX +noall +answer
    or $ dig -t MX redhat.com +noall +answer 後者`-t`表明查詢類型,能夠是`A`,`MX`,`NS`等,`+noall` 表明清除全部顯示的選項 

###4. 查詢域名服務器

$ dig -t NS chenrongrong.info +noall +answer 

###5. 查詢全部DNS記錄

$ dig -t ANY chenrongrong.info +answer ; <<>> DiG 9.9.5-3ubuntu0.1-Ubuntu <<>> -t ANY chenrongrong.info +noall +answer ;; global options: +cmd chenrongrong.info. 568 IN A 103.245.222.133 chenrongrong.info. 568 IN NS f1g1ns2.dnspod.net. chenrongrong.info. 568 IN NS f1g1ns1.dnspod.net. chenrongrong.info. 568 IN SOA f1g1ns1.dnspod.net.freednsadmin.dnspod.com. 1417233166 3600 180 1209600 180 

###6. 簡潔顯示+short

+short參數只顯示nameserver $ dig -t NS chenrongrong.info +short

f1g1ns2.dnspod.net.
    f1g1ns1.dnspod.net.

###7. DNS反向解析dig -x

咱們通常所說的DNS域名解析指的是正向解析即從域名解析到相應的IP,反之從IP解析到對應的DNS服務器就是反向解析,8.8.8.8是google的一個公共DNS服務器,咱們能夠經過dig -x查找該ip對應的DNS服務器

$ dig -x 8.8.8.8 +short google-public-dns-a.google.com. 

8.顯示域名的CNAME記錄

CNAME記錄,即:別名記錄。這種記錄容許您將多個名字映射到同一臺計算機.

dig cname www.baidu.com +short www.a.shifen.com. 

dig能夠使咱們更好的理解DNS解析的過程,dig -h列出了更多詳細的命令參數可供咱們使用,這也是學習命令有效方式:

Ask Itself,Ask Manpage

相關文章
相關標籤/搜索