DNS 递归查询
![image-20211021220243478](https://i.loli.net/2021/10/21/NhS4BJayZOb5Rsr.png)
![image-20211021220309927](https://i.loli.net/2021/10/21/F6BpzLSHvxuRmiE.png)
根域名服务器:13 个域名分布在一千多个服务器上,使用 任播技术 发现最近的根域名服务器
顶级域名服务器(Top Level Domain,TLD):比如 com、cn、net、org、等
权威域名服务器(Authoritative Domain):比如 bilibili、qq、baidu、等,管理各自的主机
![image-20211021221708757](https://i.loli.net/2021/10/21/aL6wE4IN37Tnlg1.png)
使用 nslookup 模拟递归查询 www.bilibili.com
![image-20211021221733064](https://i.loli.net/2021/10/21/2ftFEHsecnpZ4o8.png)
set type=ns # name server
set type=a # address
server dns-ip # 和服务器通话
------------------
> set type=ns # 查找形式
> . # 1. 查找根域名服务器
服务器: UnKnown
Address: 202.204.193.153
非权威应答:
(root) nameserver = b.root-servers.net
(root) nameserver = l.root-servers.net
(root) nameserver = f.root-servers.net
(root) nameserver = g.root-servers.net
(root) nameserver = h.root-servers.net
(root) nameserver = m.root-servers.net
(root) nameserver = a.root-servers.net
(root) nameserver = c.root-servers.net
(root) nameserver = j.root-servers.net
(root) nameserver = k.root-servers.net
(root) nameserver = i.root-servers.net
(root) nameserver = d.root-servers.net
(root) nameserver = e.root-servers.net
>
> set type=a # 查看地址
> g.root-servers.net # 查看这个根域名服务器的地址
服务器: UnKnown
Address: 202.204.193.153
非权威应答:
名称: g.root-servers.net
Address: 192.112.36.4
> server 192.112.36.4 # 与根域名服务器通话
默认服务器: G.ROOT-SERVERS.NET
Address: 192.112.36.4
> set type=ns
>
> com. # 2. 向根域名服务器咨询 com 域名服务器地址
服务器: G.ROOT-SERVERS.NET
Address: 192.112.36.4
com nameserver = a.gtld-servers.net
com nameserver = d.gtld-servers.net
com nameserver = f.gtld-servers.net
com nameserver = h.gtld-servers.net
com nameserver = g.gtld-servers.net
com nameserver = j.gtld-servers.net
com nameserver = c.gtld-servers.net
com nameserver = b.gtld-servers.net
com nameserver = l.gtld-servers.net
com nameserver = k.gtld-servers.net
com nameserver = e.gtld-servers.net
com nameserver = m.gtld-servers.net
com nameserver = i.gtld-servers.net
a.gtld-servers.net internet address = 192.5.6.30
b.gtld-servers.net internet address = 192.33.14.30
c.gtld-servers.net internet address = 192.26.92.30
d.gtld-servers.net internet address = 192.31.80.30
e.gtld-servers.net internet address = 192.12.94.30
f.gtld-servers.net internet address = 192.35.51.30
g.gtld-servers.net internet address = 192.42.93.30
h.gtld-servers.net internet address = 192.54.112.30
i.gtld-servers.net internet address = 192.43.172.30
j.gtld-servers.net internet address = 192.48.79.30
k.gtld-servers.net internet address = 192.52.178.30
l.gtld-servers.net internet address = 192.41.162.30
m.gtld-servers.net internet address = 192.55.83.30
a.gtld-servers.net AAAA IPv6 address = 2001:503:a83e::2:30
b.gtld-servers.net AAAA IPv6 address = 2001:503:231d::2:30
>
>
> server 192.5.6.30 # 与其中一台顶级域名服务器(gtld,通用顶级域名服务器)建立连接
in-addr.arpa nameserver = f.in-addr-servers.arpa
in-addr.arpa nameserver = a.in-addr-servers.arpa
in-addr.arpa nameserver = c.in-addr-servers.arpa
in-addr.arpa nameserver = d.in-addr-servers.arpa
in-addr.arpa nameserver = e.in-addr-servers.arpa
in-addr.arpa nameserver = b.in-addr-servers.arpa
a.in-addr-servers.arpa internet address = 199.180.182.53
b.in-addr-servers.arpa internet address = 199.253.183.183
c.in-addr-servers.arpa internet address = 196.216.169.10
d.in-addr-servers.arpa internet address = 200.10.60.53
e.in-addr-servers.arpa internet address = 203.119.86.101
f.in-addr-servers.arpa internet address = 193.0.9.1
a.in-addr-servers.arpa AAAA IPv6 address = 2620:37:e000::53
b.in-addr-servers.arpa AAAA IPv6 address = 2001:500:87::87
c.in-addr-servers.arpa AAAA IPv6 address = 2001:43f8:110::10
d.in-addr-servers.arpa AAAA IPv6 address = 2001:13c7:7010::53
e.in-addr-servers.arpa AAAA IPv6 address = 2001:dd8:6::101
f.in-addr-servers.arpa AAAA IPv6 address = 2001:67c:e0::1
默认服务器: [192.5.6.30]
Address: 192.5.6.30
>
>
> set type=ns
>
> bilibili.com. # 3. 向顶级域名服务器咨询 bilibili.com 域名服务器的地址
服务器: [192.5.6.30]
Address: 192.5.6.30
bilibili.com nameserver = ns3.dnsv5.com
bilibili.com nameserver = ns4.dnsv5.com
ns3.dnsv5.com internet address = 129.211.176.212
ns3.dnsv5.com internet address = 162.14.18.188
ns3.dnsv5.com internet address = 162.14.24.251
ns3.dnsv5.com internet address = 162.14.25.251
ns3.dnsv5.com internet address = 18.194.2.137
ns3.dnsv5.com internet address = 183.192.201.94
ns3.dnsv5.com internet address = 223.166.151.16
ns3.dnsv5.com AAAA IPv6 address = 2402:4e00:1430:1102:0:9136:2b2b:ba61
ns3.dnsv5.com internet address = 52.77.238.92
ns3.dnsv5.com internet address = 61.151.180.51
ns4.dnsv5.com internet address = 101.226.220.12
ns4.dnsv5.com internet address = 129.211.176.151
ns4.dnsv5.com internet address = 162.14.24.248
ns4.dnsv5.com internet address = 162.14.25.248
ns4.dnsv5.com internet address = 183.192.164.119
ns4.dnsv5.com internet address = 223.166.151.126
ns4.dnsv5.com AAAA IPv6 address = 2402:4e00:1020:1264:0:9136:29b6:fc32
ns4.dnsv5.com internet address = 52.198.159.146
ns4.dnsv5.com internet address = 59.36.120.147
>
> server 129.211.176.212
(root) nameserver = f.root-servers.net
(root) nameserver = g.root-servers.net
(root) nameserver = h.root-servers.net
(root) nameserver = i.root-servers.net
(root) nameserver = j.root-servers.net
(root) nameserver = k.root-servers.net
(root) nameserver = l.root-servers.net
(root) nameserver = m.root-servers.net
(root) nameserver = a.root-servers.net
(root) nameserver = b.root-servers.net
(root) nameserver = c.root-servers.net
(root) nameserver = d.root-servers.net
(root) nameserver = e.root-servers.net
默认服务器: [129.211.176.212]
Address: 129.211.176.212
>
> set type=a
>
> mail.bilibili.com. # 4. 向权威域名服务器咨询 www.bilibili.com 域名服务器的地址
Server: 129.211.176.212
Address: 129.211.176.212#53
mail.bilibili.com canonical name = mail.bilibili.com.w.cdngslb.com.
>
> space.bilibili.com.
Server: 129.211.176.212
Address: 129.211.176.212#53
space.bilibili.com canonical name = a.w.bilicdn1.com.
>
> www.bilibili.com.
Server: 129.211.176.212
Address: 129.211.176.212#53
www.bilibili.com canonical name = a.w.bilicdn1.com.
参考
沉舟侧畔千帆过,病树前头万木春。