bind9主从配置DNS

1、在从服务器安装bind

[root@centos6 ~]# yum install bind -y

[root@centos6 ~]# cat /etc/named.conf

//

// named.conf

//

// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS

// server as a caching only nameserver (as a localhost DNS resolver only).

//

// See /usr/share/doc/bind*/sample/ for example named configuration files.

//

options {

listen-on port 53 { 127.0.0.1;10.0.5.108; };  #添加本机的IP

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    { localhost; };

recursion yes;

dnssec-enable no;

dnssec-validation no;

/* Path to ISC DLV key */

bindkeys-file "/etc/named.iscdlv.key";

managed-keys-directory "/var/named/dynamic";

};

logging {

        channel default_debug {

                file "data/named.run";

                severity dynamic;

        };

};

zone "." IN {

type hint;

file "named.ca";

};

include "/etc/named.rfc1912.zones";

include "/etc/named.root.key";

2、在从服务器上配置slave定义从区域

vim /etc/named.rfc1912.zones

zone "safeidc.cn" IN {

        type slave;

        file "slaves/safeidc.cn.zone";

        masters { 10.0.5.105; };    #主DNS的地址

};

在主服务器上的safeid.cn.zone添加从服务器的地址

[root@centos6 named]# tail -20 safeidc.cn.zone

$TTL 3600

@ IN SOA @ rname.invalid. (

0 ; serial

1D ; refresh

1H ; retry

1W ; expire

3H ) ; minimum

@ NS ns1

@ NS ns2

ns1  A 10.0.5.105

ns2  A 10.0.5.108 #从dns的地址

www    A 10.0.5.106

bbs A 10.0.5.107

web CNAME www

mx CNAME www

主服务器检查配置文件:

[root@centos6 named]# named-checkzone safeidc.cn safeidc.cn.zone

zone safeidc.cn/IN: loaded serial 0

OK

[root@centos6 named]# service  named restart

从服务器上

[root@centos6 named]# service  named restart

并查看/var/named/slaves是否有同步过来主服务器的配置文件

[root@centos6 slaves]# pwd

/var/named/slaves

[root@centos6 slaves]# ls

safeidc.cn.zone

验证解析:

[root@centos6 slaves]# dig bbs.safeidc.cn @10.0.5.108

;; QUESTION SECTION:

;bbs.safeidc.cn. IN A

;; ANSWER SECTION:

bbs.safeidc.cn. 3600 IN A 10.0.5.107

;; AUTHORITY SECTION:

safeidc.cn. 3600 IN NS ns2.safeidc.cn.

safeidc.cn. 3600 IN NS ns1.safeidc.cn.

;; ADDITIONAL SECTION:

ns1.safeidc.cn. 3600 IN A 10.0.5.105

ns2.safeidc.cn. 3600 IN A 10.0.5.108

#############################################

你可能感兴趣的:(bind9主从配置DNS)