搭建DNS转发服务器
搭建DNS转发服务器
一、安装DNS服务:
yum install -y bind bind-chroot bind-utis
设置防火墙端口用例外:
firewall-cmd --add-service=dns --permanent firewall-cmd --reload
二、修改主配置文件
vim /etc/named.conf
修改后options部分内容如下:
options { listen-on port 53 { any; }; listen-on-v6 port 53 { any; }; directory "/var/named"; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt"; memstatistics-file "/var/named/data/named_mem_stats.txt"; recursing-file "/var/named/data/named.recursing"; secroots-file "/var/named/data/named.secroots"; allow-query { any; }; /* - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion. - If you are building a RECURSIVE (caching) DNS server, you need to enable recursion. - If your recursive DNS server has a public IP address, you MUST enable access control to limit queries to your legitimate users. Failing to do so will cause your server to become part of large scale DNS amplification attacks. Implementing BCP38 within your network would greatly reduce such attack surface */ recursion yes; forward only; forwarders { 114.114.114.114; 223.5.5.5; };
主要修改以下内容:
重启服务:systemctl restart named
三、测试转发DNS服务器的可用性
使用dig命令指定测试刚配置好的DNS服务器:
dig www.google.com @127.0.0.1
如出现如下绿色提示框中提示,则表示成功!