系统环境:CentOS 6.5 mini
IP地址:192.168.100.100
1.安装相关软件包
# yum install -y bind* caching-nameserver
2.防火墙端口开放
# vi /etc/sysconfig/iptables
-AINPUT -m state --state NEW -m tcp -p tcp --dport 53 -j ACCEPT
-AINPUT -m state --state NEW -m udp -p udp --dport 53 -j ACCEPT
-AINPUT -m state --state NEW -m tcp -p tcp --dport 953 -j ACCEPT
# service iptables restart
# /etc/rc.d/init.d/iptables save
3.关闭selinux
# vi /etc/selinux/config
SELINUX=disabled
4.修改named.conf
# vi /etc/named.conf
listen-on port 53 { any; }; listen-on-v6 port 53 { any; }; allow-query { any; };
5.在bind的主配置文件中添加该域
# vi /etc/named.rfc1912.zones
zone "baidu.com" IN{ type master; file "baidu.com.zone"; }; zone "doiido.com" IN{ type master; file "doiido.com.zone"; }; zone "1.10.in-addr.arpa" IN { type master; file "1.10.zone"; };
6.创建域的zone文件
(这里的文件名必须是和上面一样)
# cd /var/named
# touch baidu.com.zone
# touch doiido.com.zone
# touch 1.10.zone
7.编辑zone文件
# vi baidu.com.zone
$TTL 86400 @ IN SOA ns.baidu.com. root ( 1 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum @ IN NS ns.baidu.com. ns IN A 115.239.211.110 www IN A 115.239.211.110
# vi doiido.com.zone
$TTL 86400 @ IN SOA ns.doiido.com. root ( 1 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum @ IN NS ns.doiido.com. ns IN A 1.1.1.1 www IN A 1.1.1.1
# vi 1.10.zone
$TTL 86400 @ IN SOA ns.doiido.com. ns.baidu.com. ( 12 ; serial 28800 ; refresh 14400 ; retry 3600000 ; expire 86400 ) ; minimum @ IN NS ns.doiido.com. 1 IN PTR www.doiido.com. 110 IN PTR www.baidu.com.
8.修改刚才添加的域文件的权限
# chmod o+r /var/named/*
9.修改resolv.conf文件
# vi /etc/resolv.conf
nameserver 192.168.100.100
10.测试配置文件
# named-checkzone doiido.com /var/named/doiido.com.zone
# named-checkzone baidu.com /var/named/baidu.com.zone
11.重新启动named服务
# service named restart