因此要解决这两个dns需要查找.如果我错了,请纠正我.
解决方法
以下是针对www.google.com查询的tcpdumps片段旁边的挖掘片段到新启动的名称服务器,因此不使用缓存.为了清晰起见,我修剪了一些时间戳.
首先,本地名称服务器(此处为192.168.10.10)询问其中一个根服务器(在本例中为h.root-servers.net,128.63.2.53)查询“什么是www.google.com的A记录?” h.root-servers.net对www.google.com不具有权威性,但它确实有.com的委托,所以它返回.
192.168.10.10.17203 > 128.63.2.53.53: 29969 [1au] A? www.google.com. (43) 128.63.2.53.53 > 192.168.10.10.17203: 29969- 0/15/16 (719) ;; QUESTION SECTION: ;www.google.com. IN A ;; AUTHORITY SECTION: com. 172800 IN NS a.gtld-servers.net. com. 172800 IN NS b.gtld-servers.net. com. 172800 IN NS c.gtld-servers.net. com. 172800 IN NS d.gtld-servers.net. com. 172800 IN NS e.gtld-servers.net. com. 172800 IN NS f.gtld-servers.net. com. 172800 IN NS g.gtld-servers.net. com. 172800 IN NS h.gtld-servers.net. com. 172800 IN NS i.gtld-servers.net. com. 172800 IN NS j.gtld-servers.net. com. 172800 IN NS k.gtld-servers.net. com. 172800 IN NS l.gtld-servers.net. com. 172800 IN NS m.gtld-servers.net.
其次,本地名称服务器然后从h.root-servers.net返回的列表中选择一个名称服务器并发送相同的查询:“www.google.com的A记录是什么?”在这种情况下,查询的名称服务器是f.gtld-servers.net(192.35.51.30). f.gtld-servers.net是.com的权威,已回复了google.com专区的域名服务器代表团
192.168.10.10.65182 > 192.35.51.30.53: 58632 [1au] A? www.google.com. (43) 192.35.51.30.53 > 192.168.10.10.65182: 58632- 0/4/5 (179) ;; QUESTION SECTION: ;www.google.com. IN A ;; AUTHORITY SECTION: google.com. 172800 IN NS ns2.google.com. google.com. 172800 IN NS ns1.google.com. google.com. 172800 IN NS ns3.google.com. google.com. 172800 IN NS ns4.google.com.
越来越近!现在,本地名称服务器在最后一个响应中选择一个名称服务器并询问相同的问题.在这种情况下,它会询问ns2.google.com(216.239.34.10). ns2.google.com回复说www.google.com实际上是www.l.google.com的CNAME(规范名称)记录
192.168.10.10.4767 > 216.239.34.10.53: 15830 [1au] A? www.google.com. (43) 216.239.34.10.53 > 192.168.10.10.4767: 15830*- 6/0/0 CNAME[|domain] ;; QUESTION SECTION: ;www.google.com. IN A ;; ANSWER SECTION: www.google.com. 604800 IN CNAME www.l.google.com.
很接近!现在我们只需要www.l.google.com的地址.现在因为我们已经知道google.com的名称服务器,我们只问其中一个.在这种情况下,我们要求ns3.google.com(216.239.36.10)“www.l.google.com的A记录是什么.”它回复了地址,我们得到了答案:
192.168.10.10.63657 > 216.239.36.10.53: 62511 [1au] A? www.l.google.com. (45) 216.239.36.10.53 > 192.168.10.10.63657: 62511*- 5/0/0 A[|domain] ;; QUESTION SECTION: ;www.l.google.com. IN A ;; ANSWER SECTION: www.l.google.com. 300 IN A 74.125.232.116 www.l.google.com. 300 IN A 74.125.232.112 www.l.google.com. 300 IN A 74.125.232.115 www.l.google.com. 300 IN A 74.125.232.113 www.l.google.com. 300 IN A 74.125.232.114
好哇!
无论如何,我希望这足以让你开始.那里有很多很棒的资源. O’Reilly的书“DNS和BIND”非常有用.
我强烈建议安装dig来查看DNS查询的用途.例如,您可以使用dig trace轻松查看主机的委派路径:
; <<>> DiG 9.7.0-P1 <<>> +trace www.google.com ;; global options: +cmd . 516930 IN NS k.root-servers.net. . 516930 IN NS g.root-servers.net. . 516930 IN NS h.root-servers.net. . 516930 IN NS j.root-servers.net. . 516930 IN NS a.root-servers.net. . 516930 IN NS m.root-servers.net. . 516930 IN NS b.root-servers.net. . 516930 IN NS f.root-servers.net. . 516930 IN NS d.root-servers.net. . 516930 IN NS c.root-servers.net. . 516930 IN NS l.root-servers.net. . 516930 IN NS i.root-servers.net. . 516930 IN NS e.root-servers.net. ;; Received 244 bytes from 127.0.0.1#53(127.0.0.1) in 1 ms com. 172800 IN NS i.gtld-servers.net. com. 172800 IN NS j.gtld-servers.net. com. 172800 IN NS c.gtld-servers.net. com. 172800 IN NS l.gtld-servers.net. com. 172800 IN NS d.gtld-servers.net. com. 172800 IN NS h.gtld-servers.net. com. 172800 IN NS a.gtld-servers.net. com. 172800 IN NS e.gtld-servers.net. com. 172800 IN NS b.gtld-servers.net. com. 172800 IN NS g.gtld-servers.net. com. 172800 IN NS f.gtld-servers.net. com. 172800 IN NS k.gtld-servers.net. com. 172800 IN NS m.gtld-servers.net. ;; Received 492 bytes from 202.12.27.33#53(m.root-servers.net) in 45 ms google.com. 172800 IN NS ns2.google.com. google.com. 172800 IN NS ns1.google.com. google.com. 172800 IN NS ns3.google.com. google.com. 172800 IN NS ns4.google.com. ;; Received 168 bytes from 192.33.14.30#53(b.gtld-servers.net) in 42 ms www.google.com. 604800 IN CNAME www.l.google.com. www.l.google.com. 300 IN A 74.125.232.115 www.l.google.com. 300 IN A 74.125.232.113 www.l.google.com. 300 IN A 74.125.232.116 www.l.google.com. 300 IN A 74.125.232.114 www.l.google.com. 300 IN A 74.125.232.112 ;; Received 132 bytes from 216.239.34.10#53(ns2.google.com) in 131 ms
请注意它之前与查询的跟踪有多相似?希望有所帮助.