软件安装
安装软件包 bind 和 bind-utils:
1
| yum -y install bind bind-utils
|
修改主配置文件
服务监听
修改文件:”/etc/named.conf”
1 2 3 4 5 6 7 8 9
| listen-on port 53 { 127.0.0.1; }; listen-on port 53 { any; };
listen-on-v6 port 53 { any; };
allow-query { localhost; }; allow-query { any; };
|
正向区域
将域名转换为 IP 地址的过程。
修改文件:”/etc/named.conf”
1 2 3 4
| zone "example.com." IN { type master; file "example.com.zone"; };
|
反向区域
将 IP 地址转换成域名的过程。
IPv4
修改文件:”/etc/named.conf”
1 2 3 4
| zone "110.168.192.in-addr.arpa" IN { type master; file "example.com.arpa"; };
|
IPv6
修改文件:”/etc/named.conf”
1 2 3 4
| zone "0.0.0.0.0.0.0.0.d.c.b.0.1.2.0.2.ip6.arpa" IN { type master; file "example.com.arpa"; };
|
创建区域配置文件
1 2 3
| cd /var/named/ cp -a named.localhost example.com.zone cp -a named.loopback example.com.arpa
|
编辑区域配置文件
正向区域
修改文件:”/var/named/example.com.zone”
1 2 3 4
| dns A 192.168.1.252 nas A 192.168.1.251 client A 192.168.1.102 cool AAAA 2001:da8::1
|
反向区域
修改文件:”/var/named/example.com.arpa”
1 2 3 4 5
| @ NS dns.example.com. 252 PTR dns.example.com. 251 PTR nas.example.com. 102 PTR client.example.com. 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 PTR dns.example.com.
|
防火墙放行
方法一 放行服务
1
| firewall-cmd --add-service=dns --per
|
方法二 放行端口
1 2
| firewall-cmd --add-port=53/tcp --per firewall-cmd --add-port=53/udp --per
|
重载防火墙配置
重启 Bind 服务
开机自启
1
| systemctl enable named [-now(设置完成后立即启动)]
|
重启服务
重载配置