配置规划:(vmware9下RHEL5.8系统实现)
在cqy.com域中,在192.168.0.0/24网段
ns服务器:192.168.0.150;
www服务器:192.168.0.151,192.168.0.152
mail服务器:192.168.0.153
ftp服务器是www服务器的别名
配置主从服务器,从服务器IP:192.168.0.160
主服务器内授权一个子服务器,IP:192.168.0.170,并实现子服务器可以解析父域
注意:必须确保服务器防火墙不阻隔dns流量
# service iptables stop 关闭防火墙
在主服务器上的配置:
一、安装bind97软件包
1、配置好yum源
[root@localhost ~]# cat /etc/yum.repos.d/local.repo [base] name=Server baseurl=file:///media/cdrom/Server enabled=1 gpgcheck=0
2、删除redhat自动安装的bind93的两个软件包bind-libs和bind-utils
# rpm -e bind-libs bind-utils
3.安装bind97主包以及其子包
# yum install bind97-libs bind97-utils
# yum install bind97 -y
二、配置bind97的主配置文件:/etc/named.conf
1、删除或重命名安装时产生的官方主配置文件
# mv /etc/named.conf /etc/named.conf.orgi
2、创建一个新的配置文件/etc/named.conf,并添加如下内容
[root@localhost named]# cat /etc/named.conf options { directory "/var/named"; allow-recursion { 192.168.0.0/24; 127.0.0.0/8; }; }; zone "." { type hint; file "named.ca"; }; zone "localhost" { type master; file "named.localhost"; allow-transfer { none; }; }; zone "0.0.127.in-addr.arpa" { type master; file "named.loopback"; allow-transfer { 192.168.0.160; }; }; zone "cqy.com" { type master; file "cqy.com.zone"; allow-transfer { 192.168.0.160; }; }; zone "0.168.192.in-addr.arpa" { type master; file "192.168.0.zone"; allow-transfer { 192.168.0.160; }; };
3、修改配置文件的属组和权限
# chown root:namde /etc/named.conf
# chmod 640 /etc/named.conf
三、配置区域数据文件:/var/namd/下
创建并配置在主配置文件中解析的两个正反向区域文件 cqy.com.zone 和 192.168.0.zone
[root@localhost named]# cat cqy.com.zone $TTL 600 cqy.com. IN SOA ns1.cqy.com. admin.cqy.com. ( 2015082001 1H 5M 2D 6H ) NS ns1 NS ns2 MX 10 mail ns1 IN A 192.168.0.150 ns2 IN A 192.168.0.160 mail IN A 192.168.0.152 www IN A 192.168.0.150 www IN A 192.168.0.151 ftp IN CNAME www [root@localhost named]# cat 192.168.0.zone $TTL 600 @ IN SOA ns1.cqy.com. admin.cqy.com. ( 2015081901 1H 5M 2D 6H ) NS ns1.cqy.com. NS ns2.cqy.com. 150 IN PTR ns1.cqy.com. 150 IN PTR www.cqy.com. 152 IN PTR mail.cqy.com. 151 IN PTR www.cqy.com. 160 IN PTR ns2.cqy.com.
四、编辑/etc/resolv.conf文件,修改其nameserver为本机的IP
# vim /etc/resolv.conf
nameserver 192.168.0.150
search localdomain
五、关闭SElinux
# setenforce 0 关闭SElinux
# getenforce 查看
[root@localhost named]# getenforce Enforcing [root@localhost named]# setenforce 0 [root@localhost named]# getenforce Permissive
六、检查配置文件以及正反向区域文件是否错误
# named-checkconf
# named-checkzone "cqy.com" /var/named/cqy.com
# named-checkzone "0.168.192.in-addr.arpa" /var/named/192.168.0.zone
七、重启或重读dns服务器
# service named restart|reload
在从服务器上的配置:
步骤同主服务器,不同点在于/etc/named.conf,且不用手动创建区域数据文件
一、创建主配置文件,编辑如下
[root@localhost named]# cat /etc/named.conf options { directory "/var/named"; allow-recursion { 192.168.0.0/24; 127.0.0.0/8; }; }; zone "." { type hint; file "named.ca"; }; zone "localhost" { type master; file "named.localhost"; allow-transfer { none; }; }; zone "0.0.127.in-addr.arpa" { type master; file "named.loopback"; allow-transfer { none; }; }; zone "cqy.com" { type slave; file "slaves/cqy.com.zone"; masters { 192.168.0.150; }; allow-transfer { none; }; }; zone "0.168.192.in-addr.arpa" { type slave; file "slaves/192.168.0.zone"; masters { 192.168.0.150; }; allow-transfer { none; }; };
子域授权
主服务器上的配置
一、在区域文件/var/named/cqy.com.zone中添加如下
fin IN NS ns1.fin ns1.fin IN A 192.168.0.170
二、重启或重读dns服务器
# service named restart|reload
子服务器上的配置
一、创建/etc/named.conf,并添加如下内容
options { directory "/var/named"; allow-recursion { 192.168.0.0/24; 127.0.0.1; }; }; zone "." IN { type hint; file "named.ca"; }; zone "localhost" IN { type master; file "named.localhost"; allow-transfer { none; }; }; zone "0.0.127.in-addr.arpa" IN { type master; file "named.loopback"; allow-transfer { none; }; }; zone "fin.cqy.com" IN { type master; file "fin.cqy.com.zone"; }; zone "cqy.com" IN { type forward; forward first; forwarders { 192.168.0.150; }; };
二、修改/etc/named.conf属组和权限
# chown root:namde /etc/named.conf
# chmod 640 /etc/named.conf
三、创建/var/named/fin.cqy.com.zone并添加如下内容:
$TTL 600 fin.cqy.com. IN SOA ns1.fin.cqy.com. admin.fin.cqy.com. ( 2015081901 1H 5M 2D 6H ) NS ns1 MX 10 mail ns1 IN A 192.168.0.170 mail IN A 192.168.0.172 www IN A 192.168.0.171
四、修改文件权限如下
[root@localhost named]# ll fin.cqy.com.zone -rw-r----- 1 root named 211 Aug 20 08:13 fin.cqy.com.zone
五、重启或重读dns服务器
# service named restart|reload
原文地址:http://chenqiyi.blog.51cto.com/8125763/1686633