DNS-01-缓存服务器
实验环境
ns1.magedu.com 172.18.71.101/24 CentOS-6.7-x86_64
iptables
与SELinux
均处于关闭状态。
安装bind
[[email protected] ~]# yum install -y bind bind-libs bind-utils
首先,修改主配置文件/etc/named.conf
,注释掉仅允许本机查询请求和dnssec
(可能影响实验结果),并在监听地址列表中增加各自向外部提供服务的IP
地址。
options { listen-on port 53 { 127.0.0.1; 172.18.71.101; }; ... //allow-query { localhost; }; ... //dnssec-enable yes; //dnssec-validation yes; //dnssec-lookaside auto; ... };
直接启动服务,即是一个缓存域名服务器。
[[email protected] named]# /etc/init.d/named start Generating /etc/rndc.key: [ OK ] Starting named: [ OK ]
使用dig
命令的+trace
选项,可以查看它的工作流程。
[[email protected] named]# dig +trace -t A www.magedu.com @172.18.71.101 ; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6 <<>> +trace -t A www.magedu.com @172.18.71.101 ;; global options: +cmd . 515840 IN NS d.root-servers.net. . 515840 IN NS m.root-servers.net. . 515840 IN NS f.root-servers.net. . 515840 IN NS h.root-servers.net. . 515840 IN NS j.root-servers.net. . 515840 IN NS i.root-servers.net. . 515840 IN NS g.root-servers.net. . 515840 IN NS l.root-servers.net. . 515840 IN NS b.root-servers.net. . 515840 IN NS c.root-servers.net. . 515840 IN NS e.root-servers.net. . 515840 IN NS k.root-servers.net. . 515840 IN NS a.root-servers.net. ;; Received 228 bytes from 172.18.71.101#53(172.18.71.101) in 4603 ms com. 172800 IN NS a.gtld-servers.net. com. 172800 IN NS l.gtld-servers.net. com. 172800 IN NS j.gtld-servers.net. com. 172800 IN NS g.gtld-servers.net. com. 172800 IN NS e.gtld-servers.net. com. 172800 IN NS b.gtld-servers.net. com. 172800 IN NS f.gtld-servers.net. com. 172800 IN NS m.gtld-servers.net. com. 172800 IN NS i.gtld-servers.net. com. 172800 IN NS k.gtld-servers.net. com. 172800 IN NS h.gtld-servers.net. com. 172800 IN NS d.gtld-servers.net. com. 172800 IN NS c.gtld-servers.net. ;; Received 492 bytes from 199.7.91.13#53(199.7.91.13) in 6665 ms magedu.com. 172800 IN NS v2s1.xundns.com. magedu.com. 172800 IN NS v2s2.xundns.com. ;; Received 221 bytes from 192.31.80.30#53(192.31.80.30) in 3054 ms www.magedu.com. 600 IN A 101.200.188.230 magedu.com. 7200 IN NS v2s2.xundns.com. magedu.com. 7200 IN NS v2s1.xundns.com. ;; Received 93 bytes from 115.238.241.20#53(115.238.241.20) in 369 ms
可以看到它是先直接去找根域名服务器,然后去找com.
域名服务器,然后去找magedu.com.
域名服务器,这样层层递归查询的。
时间: 2024-12-24 22:14:17