CentOS 下的名字服务的部署和基础配置:
安装包
先安装相关软件包。
yum install bind-chroot bind-utils -y
编辑 /etc/named.conf 文件,在 option 配置中编辑 listen-on 与 allow-query 选项,前者添加额外的服务监听端口,后者添加授权查询请求主机。
options { listen-on port 53 { 127.0.0.1; 10.1.1.1; 10.1.2.1; }; ... allow-query { localhost; 10.1.1.0/24; 10.1.2.0/24; }; .... } zone "test.local" IN { type master; file "test.local.zone"; allow-update { none; }; };
创建和编辑简单区域文件
创建文件 /var/named/test.local.zone 并编辑以下内容
$ORIGIN test.local. $TTL 86400 @ IN SOA dns1.test.local. root.test.local. ( 2021122501 ; serial 21600 ; refresh after 6 hours 3600 ; retry after 1 hour 604800 ; expire after 1 week 86400 ) ; minimum TTL of 1 day @ IN NS dns1.test.local. dns1 IN A 10.1.1.1 @ IN A 10.1.1.1 www IN CNAME test.local.
编辑完成名字区域文件后建议使用命令检查一下合法性:
named-checkzone test.local /var/named/test.local.zone
启动名字服务:
systemctl enable named-chroot systemctl start named-chroot