DNSテストツール


一、digコマンド


dig-dnsシステムをテストするため、hostsファイルをクエリーして解析する.
#  : dig [@dns_server] [-t rr_type] name [query option]

順方向解析テスト:
#  : dig -t A FQDN [@dns_server]
#  :
[root@leistudy named]# dig -t A www.leistudy.com @192.168.123.100

; <<>> DiG 9.9.4-RedHat-9.9.4-51.el7_4.2 <<>> -t A www.leistudy.com @192.168.123.100
;; global options: +cmd
;; Got answer:
;; ->>HEADER<

query option:
# query option
    # +[no]trace:  
    # +[no]recurse:  

#  :
[root@leistudy named]# dig -t A www.baidu.com +trace  

; <<>> DiG 9.9.4-RedHat-9.9.4-51.el7_4.2 <<>> -t A www.baidu.com +trace
;; global options: +cmd
.                       5       IN      NS      l.root-servers.net.
.                       5       IN      NS      i.root-servers.net.
.                       5       IN      NS      e.root-servers.net.
.                       5       IN      NS      j.root-servers.net.
.                       5       IN      NS      b.root-servers.net.
.                       5       IN      NS      c.root-servers.net.
.                       5       IN      NS      a.root-servers.net.
.                       5       IN      NS      f.root-servers.net.
.                       5       IN      NS      d.root-servers.net.
.                       5       IN      NS      k.root-servers.net.
.                       5       IN      NS      h.root-servers.net.
.                       5       IN      NS      g.root-servers.net.
.                       5       IN      NS      m.root-servers.net.
;; Received 239 bytes from 192.168.123.2#53(192.168.123.2) in 836 ms

com.                    172800  IN      NS      a.gtld-servers.net.
com.                    172800  IN      NS      b.gtld-servers.net.

... #  ,  

a.shifen.com.           1200    IN      NS      ns1.a.shifen.com.
a.shifen.com.           1200    IN      NS      ns4.a.shifen.com.
;; Received 239 bytes from 202.108.22.220#53(dns.baidu.com) in 59 ms

逆解析テスト:
#  : dig -x IP [@dns_server] dig -t PTR IP [@dns_server]

#  :
[root@leistudy named]# dig -x 61.135.169.121 @119.29.29.29

; <<>> DiG 9.9.4-RedHat-9.9.4-51.el7_4.2 <<>> -x 61.135.169.121 @119.29.29.29
;; global options: +cmd
;; Got answer:
;; ->>HEADER<

アナログゾーン転送:
#  : dig -t axfr ZONE_NAME @dns_server

#  :  
[root@docker-package ~]# dig -t axfr leistudy.com @192.168.123.132

; <<>> DiG 9.9.4-RedHat-9.9.4-51.el7_4.2 <<>> -t axfr leistudy.com @192.168.123.132
;; global options: +cmd
leistudy.com.           86400   IN      SOA     ns1.leistudy.com. admin.leistudy.com.leistudy.com. 2018030101 3600 300 604800 86400
leistudy.com.           86400   IN      NS      ns1.leistudy.com.
leistudy.com.           86400   IN      NS      ns2.leistudy.com.
leistudy.com.           86400   IN      MX      10 mx1.leistudy.com.
leistudy.com.           86400   IN      MX      20 mx2.leistudy.com.
ftp.leistudy.com.       86400   IN      CNAME   www.leistudy.com.
mx1.leistudy.com.       86400   IN      A       192.168.123.132
mx2.leistudy.com.       86400   IN      A       192.168.123.101
ns1.leistudy.com.       86400   IN      A       192.168.123.132
ns2.leistudy.com.       86400   IN      A       192.168.123.101
www.leistudy.com.       86400   IN      A       192.168.123.132
leistudy.com.           86400   IN      SOA     ns1.leistudy.com. admin.leistudy.com.leistudy.com. 2018030101 3600 300 604800 86400
;; Query time: 3 msec
;; SERVER: 192.168.123.132#53(192.168.123.132)
;; WHEN: Sat Mar 03 10:12:28 CST 2018
;; XFR size: 12 records (messages 1, bytes 299)

#  :  
[root@docker-package ~]# dig -t axfr 123.168.192.in-addr.arpa @192.168.123.132

; <<>> DiG 9.9.4-RedHat-9.9.4-51.el7_4.2 <<>> -t axfr 123.168.192.in-addr.arpa @192.168.123.132
;; global options: +cmd
123.168.192.in-addr.arpa. 86400 IN      SOA     ns1.leistudy.com. admin.leistudy.com. 2018030101 3600 300 604800 86400
123.168.192.in-addr.arpa. 86400 IN      NS      ns1.leistudy.com.
123.168.192.in-addr.arpa. 86400 IN      NS      ns2.leistudy.com.
101.123.168.192.in-addr.arpa. 86400 IN  PTR     mx2.leistudy.com.
132.123.168.192.in-addr.arpa. 86400 IN  PTR     ns1.leistudy.com.
132.123.168.192.in-addr.arpa. 86400 IN  PTR     mx1.leistudy.com.
132.123.168.192.in-addr.arpa. 86400 IN  PTR     www.leistudy.com.
123.168.192.in-addr.arpa. 86400 IN      SOA     ns1.leistudy.com. admin.leistudy.com. 2018030101 3600 300 604800 86400
;; Query time: 1 msec
;; SERVER: 192.168.123.132#53(192.168.123.132)
;; WHEN: Sat Mar 03 10:12:50 CST 2018
;; XFR size: 8 records (messages 1, bytes 244)

二、hostコマンド


host-DNSクエリーツール.
#  : host [-t rr_type] name [dns_server]

#  1:  
[root@leistudy named]# host -t A www.leistudy.com 192.168.123.100
Using domain server:
Name: 192.168.123.100
Address: 192.168.123.100#53
Aliases: 

www.leistudy.com has address 192.168.123.100

#  2: NS 
[root@leistudy named]# host -t NS leistudy.com 192.168.123.100
Using domain server:
Name: 192.168.123.100
Address: 192.168.123.100#53
Aliases: 

leistudy.com name server ns1.leistudy.com.
leistudy.com name server ns2.leistudy.com.

三、nslookupコマンド


nslookup-ドメイン名のdns情報をクエリーし、インタラクティブに行うことができる.
#  : nslookup [option] [name|-] [server]

#  :
~]# nslookup
nslookup>
    # server IP:  DNS 
    # set q=RR_TYPE:  
    # NAME:  

[root@leistudy named]# nslookup
> server 192.168.123.100 #  dns 
Default server: 192.168.123.100
Address: 192.168.123.100#53
> www.leistudy.com #  A 
Server:         192.168.123.100
Address:        192.168.123.100#53

Name:   www.leistudy.com
Address: 192.168.123.100

> set q=NS #  NS 
> leistudy.com
Server:         192.168.123.100
Address:        192.168.123.100#53

leistudy.com    nameserver = ns1.leistudy.com.
leistudy.com    nameserver = ns2.leistudy.com.

> set q=A #  A 
> web.leistudy.com
Server:         192.168.123.100
Address:        192.168.123.100#53

web.leistudy.com        canonical name = www.leistudy.com.
Name:   www.leistudy.com
Address: 192.168.123.100