DNS客户端工具之nslookup、host、dig

DNS-学习目录

1、nslookup、host、dig难易度比较

通用性              使用                          难易度
nslookup           支持多平台、应用广泛             使用简单、易懂
dig                常用语linux系统                比较专业
host               较多                          简单、明了

2、host

2.1、查询SOA记录

# 自定义的域名
~]# host -t SOA example.com
example.com has SOA record example.com. sa.example.com. 2023051644 10800 900 604800 86400

~]# host -t SOA baidu.com
baidu.com has SOA record dns.baidu.com. sa.baidu.com. 2012146599 300 300 2592000 7200

2.2、查询NS记录

~]# host -t NS baidu.com
baidu.com name server ns3.baidu.com.
baidu.com name server ns4.baidu.com.
baidu.com name server ns2.baidu.com.
baidu.com name server dns.baidu.com.
baidu.com name server ns7.baidu.com.

2.3、查询A记录

~]# host -t A baidu.com
baidu.com has address 39.156.66.10
baidu.com has address 110.242.68.66

3、nslookup

3.1、查询A记录

~]# nslookup www.baidu.com
Server:         192.168.10.2
Address:        192.168.10.2#53

Non-authoritative answer:
www.baidu.com   canonical name = www.a.shifen.com.
Name:   www.a.shifen.com
Address: 120.232.145.144
Name:   www.a.shifen.com
Address: 120.232.145.185

3.2、查询SOA记录

~]# nslookup 
> set q=soa
> baidu.com
Server:         192.168.10.2
Address:        192.168.10.2#53

Non-authoritative answer:
baidu.com
        origin = dns.baidu.com
        mail addr = sa.baidu.com
        serial = 2012146599
        refresh = 300
        retry = 300
        expire = 2592000
        minimum = 7200

Authoritative answers can be found from:
baidu.com       nameserver = ns1.baidu.com.
baidu.com       nameserver = ns7.baidu.com.
baidu.com       nameserver = ns2.baidu.com.
baidu.com       nameserver = ns4.baidu.com.
baidu.com       nameserver = ns3.baidu.com.
ns2.baidu.com   internet address = 220.181.33.31
ns3.baidu.com   internet address = 36.152.45.193
ns3.baidu.com   internet address = 112.80.248.64
ns4.baidu.com   internet address = 14.215.178.80
ns4.baidu.com   internet address = 111.45.3.226
ns1.baidu.com   internet address = 110.242.68.134
ns7.baidu.com   internet address = 180.76.76.92
ns7.baidu.com   has AAAA address 240e:940:603:4:0:ff:b01b:589a
ns7.baidu.com   has AAAA address 240e:bf:b801:1002:0:ff:b024:26de

4、dig

4.1、通过哪个 dns 来解析域名【正向解析】

~]# dig www.baidu.com @8.8.8.8 +short
www.a.shifen.com.
120.232.145.185
120.232.145.144

4.2、查询PTR记录【反向解析】

~]# dig -x 192.168.10.18 @192.168.10.19 +short
www.example.com.

4.3、查询A记录

~]# dig -t a baidu.com +short
110.242.68.66
39.156.66.10

4.4、dig查看区域传送配置

~]# dig -t AXFR example.com @192.168.10.19

; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.13 <<>> -t AXFR example.com @192.168.10.19
;; global options: +cmd
example.com.            600     IN      SOA     example.com. sa.example.com. 2023051644 10800 900 604800 86400
example.com.            600     IN      NS      ns.example.com.
ns.example.com.         600     IN      A       192.168.10.19
test.example.com.       600     IN      A       2.2.2.2
www.example.com.        600     IN      A       1.1.1.1
example.com.            600     IN      SOA     example.com. sa.example.com. 2023051644 10800 900 604800 86400
;; Query time: 0 msec
;; SERVER: 192.168.10.19#53(192.168.10.19)
;; WHEN: Sun May 07 21:16:49 CST 2023
;; XFR size: 6 records (messages 1, bytes 189)

 

posted @ 2023-05-07 21:18  小粉优化大师  阅读(220)  评论(0编辑  收藏  举报