centos minimal Bind 主从服务器部署

请先参考

win 7 virtualbox 安装 centos 6.3 minimal

win7 virtualbox4.2.18 vdi 克隆 导入

准备好实验环境

实验环境

两台虚拟机BindM和BindS,装的系统都是centos6.3 minimal

 IP地址主机名hostname
主DNS服务器192.168.137.102bindm.cas.cn
从DNS服务器192.168.137.103binds.cas.cn
主机win7 218.241.119.9 

安装bind(针对bindm,binds)

1.让yum安装包保留在服务器上

[root@bindm grid]# vi /etc/yum.conf

2.使用yum 安装Bind (主DNS)服务器;


[root@bindm grid]# yum -y install bind  bind-utils  bind-chroot

注:新版本CentOS 6.x 已将chroot所需使用的目录,透过mount --bind的功能进行目录 链接了,故在CentOS 6.x中,根本无须切换到/var/named/chroot/了只需按常规目录操 作 即可!)请cat /etc/sysconfig/named目录,其下是不是有“ROOTDIR="/var/named/chroot

3.修改resovl.conf解析和hosts

目的是为了提高域名解析效率,需要将主从DNS的地址写入到/etc/hosts,同时在/etc/resolv.conf文件中指定主从DNS地址。

 [root@bindm etc]# vi resolv.conf

 

[root@bindm etc]# vi hosts

3、配置主DNS服务器

设置Bind配置文件

(1)设置主配置文件named.conf,其主要是设置DNS服务器能管理哪些区域(zone)以及对应文件名和存储路径;

[root@bindm etc]# vi /etc/named.conf
listen-on port 53 { any; };

注销listen-on-v6
allow-query     { any; };

注意:name.conf文件最后include 两个文件 :

修改named.rfc1912.zones

[root@bindm etc]# vi named.rfc1912.zones

添加:

zone "cas.cn" IN {
        type master;
        file "cas.cn";
        allow-transfer  {192.168.137.103;};
};

zone "137.168.192.in-addr.arpa" IN {
        type master;
        file "192.168.137.rev";
        allow-transfer  {192.168.137.103;};
};

检查:[root@bindm etc]# named-checkconf

 

(2)建立区域文件,依据named.conf文件中指定的路径来建立区域文件,此文件主要记录该区域内的资料记录;

 //正向解析配置文件: 

//检查正向区域配置文件:

[root@bindm named]# named-checkzone cas.cn. /var/named/cas.cn

 //反向解析配置文件:   

[root@bindm named]# vi 192.168.137.rev

//检查反向区域配置文件:  

[root@bindm named]# named-checkzone 137.168.192.in-addr.arpa. /var/named/192.168.137.rev

3)重新加载配置文件或重启named服务使用配置生效

[root@bindm named]# chkconfig --list named
[root@bindm named]# chkconfig named on
[root@bindm named]# chkconfig --list named
[root@bindm named]# chkconfig --add named
[root@bindm named]# service named restart

验证能否解析

[root@bindm ~]# service named restart
Stopping named: .                                          [  OK  ]
Starting named:                                            [  OK  ]
[root@bindm ~]# nslookup 
> 192.168.137.102
Server:         192.168.137.102
Address:        192.168.137.102#53

102.137.168.192.in-addr.arpa    name = bindm.cas.cn.
102.137.168.192.in-addr.arpa    name = mail.cas.cn.
102.137.168.192.in-addr.arpa    name = www.cas.cn.
> bindm.cas.cn
Server:         192.168.137.102
Address:        192.168.137.102#53

Name:   bindm.cas.cn
Address: 192.168.137.102
> mail.cas.cn
Server:         192.168.137.102
Address:        192.168.137.102#53

Name:   mail.cas.cn
Address: 192.168.137.102
> www.cas.cn
Server:         192.168.137.102
Address:        192.168.137.102#53

Name:   www.cas.cn
Address: 192.168.137.102

 

 

防火墙配置

关闭防火墙

[root@bindm etc]# service iptables stop

设置为开机不启动防火墙chkconfig iptables off

[root@bindm sysconfig]# service iptables stop
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]
[root@bindm sysconfig]# service iptables status
iptables: Firewall is not running.
[root@bindm sysconfig]# chkconfig iptables off
[root@bindm sysconfig]# 

 

4.配置从DNS服务器

修改主配置文件named.conf

主要设置DNS服务器能管理哪些区域(zone)以及对应文件名和存储路径;

[root@binds etc]# vi /etc/named.conf

修改named.rfc1912.zones

[root@binds etc]# vi named.rfc1912.zones
在文件最后添加以下内容:

zone "cas.cn"   IN      {
        type slave;
        masters {192.168.137.102;};
        file "slaves/cas.cn";
};

zone "137.168.192.in-addr.arpa" IN {
        type slave;
        masters {192.168.137.102;};
        file "slaves/192.168.137.rev";
};
检查并重启服务 :

[root@binds etc]# chkconfig --list named
[root@binds etc]# chkconfig named on
[root@binds etc]# chkconfig --list named
[root@binds etc]# chkconfig --add named
[root@binds etc]# service named restart


 数据同步测试

经过上面重启从域名服务器named服务,使其与主域名服务器数据同步,成功后,在系统日志文件中可以看到下载区域数据库文件的记录,在"/var/named/chroot/var/named/slaves/” (/var/named/slaves/)目录中也可以看到自动保存的区域数据库文件。

动态跟踪日志记录:

 [root@binds ~]# tail -f /var/log/messages

//用ll 查看/var/named/slaves/下,是否有自动保存的区域数据库文件


 验证从域名服务器

dig测试

[root@bindm ~]# dig @localhost www.cas.cn

[root@binds ~]# dig @localhost mail.cas.cn

 遇到问题

问题1:none:0: open: /etc/rndc.key: permission denied

解决方法:主从服务器执行命令(赋予rndc.key读取权限)

[root@binds etc]# chmod +r rndc.key

问题2:service named restart时, 停滞在Generating /etc/rndc.key,没有反应

解决方法:执行命令[root@binds etc]# rndc-confgen -r /dev/urandom -a,再重新执行service named restart即可.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值