BIND 主从配置

BIND 主从配置

环境:
master:172.31.182.144
slave:172.31.182.147

一、安装
yum install bind bind-chroot  -y

(源码包:https://downloads.isc.org/isc/bind9/9.14.8/bind-9.14.8.tar.gz)

二、master配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
[root@master named]# cat /etc/named.conf |grep -Ev "//|^$"
options {
    listen-on port 53 { 172.31.182.144; };
    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";
    recursing-file  "/var/named/data/named.recursing";
    secroots-file   "/var/named/data/named.secroots";
    /*
     - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
     - If you are building a RECURSIVE (caching) DNS server, you need to enable
       recursion.
     - If your recursive DNS server has a public IP address, you MUST enable access
       control to limit queries to your legitimate users. Failing to do so will
       cause your server to become part of large scale DNS amplification
       attacks. Implementing BCP38 within your network would greatly
       reduce such attack surface
    */
    recursion yes;
    dnssec-enable yes;
    dnssec-validation yes;
    /* Path to ISC DLV key */
    bindkeys-file "/etc/named.iscdlv.key";
    managed-keys-directory "/var/named/dynamic";
    pid-file "/run/named/named.pid";
    session-keyfile "/run/named/session.key";
};
logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};
zone "adfile.wifi8.com" {
        type master;
        file "adfile.wifi8.com.hosts";
        allow-transfer {172.31.182.147;};
    notify yes;
    also-notify { 172.31.182.147; }; //指定slave server的IP位址
        };
zone "." IN {
    type hint;
    file "named.ca";
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";

zone文件:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@master named]# cat /var/named/adfile.wifi8.com.hosts
$TTL 180
@       IN SOA  ns1.test.com. root.adfile.wifi8.com. ( ;
                                        22190928       ; serial
                                        10S      ; refresh
                                        1H      ; retry
                                        1M      ; expire
                                        44H )    ; minimum
                IN      NS      ns1.test.com.
                IN      NS      ns2.test.com.
ns1             IN      A       172.31.182.144
ns2             IN      A       172.31.182.147
adfile.wifi8.com. IN A 10.254.33.32
adfile.wifi8.com. IN A 10.254.33.34

各参数解析:http://dns-learning.twnic.net.tw/bind/intro6.html

启动:
systemctl  restart  named.service

三、slave配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
[root@node02 named]# cat /etc/named.conf |grep -Ev "//|^$"
options {
    listen-on port 53 { 172.31.182.147; };
    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";
    recursing-file  "/var/named/data/named.recursing";
    secroots-file   "/var/named/data/named.secroots";
    /*
     - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
     - If you are building a RECURSIVE (caching) DNS server, you need to enable
       recursion.
     - If your recursive DNS server has a public IP address, you MUST enable access
       control to limit queries to your legitimate users. Failing to do so will
       cause your server to become part of large scale DNS amplification
       attacks. Implementing BCP38 within your network would greatly
       reduce such attack surface
    */
    recursion yes;
    dnssec-enable yes;
    dnssec-validation yes;
    /* Path to ISC DLV key */
    bindkeys-file "/etc/named.iscdlv.key";
    managed-keys-directory "/var/named/dynamic";
    pid-file "/run/named/named.pid";
    session-keyfile "/run/named/session.key";
};
logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};
zone "adfile.wifi8.com" {
        type slave;
        file "adfile.wifi8.com.hosts";
        masters { 172.31.182.144; };
        };
zone "." IN {
    type hint;
    file "named.ca";
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";

启动后自动同步master解析配置:
systemctl  restart  named.service

添加域名脚本:


踩坑:
1、最后需要在主DNS服务器上的/var/named/ZONE_NAME.zone 文件里添加将该从服务的NS记录;
2、同时若想要实现主从服务器的数据同步,在修改好主服务器的/var/named/ZONE_NAME.zone 文件时,必须将该文件里的 序列号 增大才行,增大并保存退出后,主服务器会自动向从服务器推送(push)修改后的文件内容;

 

 

posted @   西门运维  阅读(1584)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类
点击右上角即可分享
微信分享提示