(2)配置仅有缓存功能的dns服务器
1.安装bind和启动服务
yum install bind bind-chroot -y
systemctl restart named
systemctl enable named
2.修改配置文件
#vim /etc/named.conf
zone "." IN {
type hint;
file "named.ca"; //根区域,文件在选项directory(var/named)配置的目录下,全球13台根服务器
};
options {
listen-on port 53 { any; }; //监听端口在所有ipv4接口上
listen-on-v6 port 53 { any; }; //监听端口在所有ipv6接口上
directory "/var/named"; //数据目录
allow-query { any; }; //允许任意主机查询
forward first; //当客户端发起查询,不是自己的区域,首先向forwarders服务器发起查询
forwarders { 114.114.114.114;114.114.115.115; }; //转发到上一级的DNS服务器
};
3.重启服务和验证测试
#systemctl restart named
说明:当客户端的dns服务器为这台服务器的时候,如果该配置里面没有forward参数,默认发起查询会向根节点发起查询,全球有13台根服务器;如果配置forward选项,客户端发起的请求会转发forward的dns
测试:客户端dns服务器指向这台服务器,dig www.baidu.com ;然后在dns服务器上tcpdump -i ens33 -nn port 53