CentOS7安装bind域名服务
安装Bind Chroot DNS 服务器
yum install bind-chroot bind -y
拷贝bind相关文件,准备bind chroot 环境
cp -R /usr/share/doc/bind-*/sample/var/named/* /var/named/chroot/var/named/
在bind chroot 的目录中创建相关文件
touch /var/named/chroot/var/named/data/cache_dump.db touch /var/named/chroot/var/named/data/named_stats.txt touch /var/named/chroot/var/named/data/named_mem_stats.txt touch /var/named/chroot/var/named/data/named.run mkdir /var/named/chroot/var/named/dynamic touch /var/named/chroot/var/named/dynamic/managed-keys.bind
将 Bind 锁定文件设置为可写
chmod -R 777 /var/named/chroot/var/named/data chmod -R 777 /var/named/chroot/var/named/dynamic
将/etc/named.conf 拷贝到 bind chroot目录
# cp -p /etc/named.conf /var/named/chroot/etc/named.conf # vi /var/named/chroot/etc/named.conf options { listen-on port 53 { xxxxxxxxxx; }; listen-on-v6 port 53 { ::1; }; 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"; allow-query { any; }; //forwarders { 114.114.114.114; }; .. .. zone "example.local" { type master; file "example.local.zone"; }; zone "0.168.192.in-addr.arpa" IN { type master; file "192.168.0.zone"; }; .. ..
为 example.local 域名创建转发域与反向域文件
1 # vi /var/named/chroot/var/named/example.local.zone 2 3 ; 4 ; Addresses and other host information. 5 ; 6 $TTL 86400 7 @ IN SOA example.local. hostmaster.example.local. ( 8 2014101901 ; Serial 9 43200 ; Refresh 10 3600 ; Retry 11 3600000 ; Expire 12 2592000 ) ; Minimum 13 14 ; Define the nameservers and the mail servers 15 16 IN NS ns1.example.local. 17 IN NS ns2.example.local. 18 IN A 192.168.0.70 19 IN MX 10 mx.example.local. 20 21 centos7 IN A 192.168.0.70 22 mx IN A 192.168.0.50 23 ns1 IN A 192.168.0.70 24 ns2 IN A 192.168.0.80
1 # vi /var/named/chroot/var/named/192.168.0.zone 2 3 ; 4 ; Addresses and other host information. 5 ; 6 $TTL 86400 7 @ IN SOA example.local. hostmaster.example.local. ( 8 2014101901 ; Serial 9 43200 ; Refresh 10 3600 ; Retry 11 3600000 ; Expire 12 2592000 ) ; Minimum 13 14 0.168.192.in-addr.arpa. IN NS centos7.example.local. 15 16 70.0.168.192.in-addr.arpa. IN PTR mx.example.local. 17 70.0.168.192.in-addr.arpa. IN PTR ns1.example.local. 18 80.0.168.192.in-addr.arpa. IN PTR ns2.example.local.
开机自启动 bind-chroot 服务
/usr/libexec/setup-named-chroot.sh /var/named/chroot on systemctl stop named systemctl disable named systemctl start named-chroot systemctl enable named-chroot ln -s '/usr/lib/systemd/system/named-chroot.service' '/etc/systemd/system/multi-user.target.wants/named-chroot.service'
每天进步一点,加油!