DNS主从服务器的搭建

1.搭建dns服务器能够对自定义的正向或者反向域完成数据解析查询。
2.配置从DNS服务器,对主dns服务器进行数据备份。

一,主服务器的配置

关闭防火墙和Linux

[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0

下载DNS

[root@localhost ~]# dnf install bind -y

 主服务器配置

options {
        listen-on port 53 { 192.168.108.129; };
        directory       "/var/named";
        allow-query     { any; };
        allow-transfer {192.168.108.130; };
};
zone "openlab.com" IN {
        type master;
        file "named.openlab.com";
};


zone "108.168.192.in-addr.arpa" IN {
        type master;
        file "named.192";
        allow-update  { none; };  //数据文件(正向或反向解析的资源记录文件)
};

 二,从服务器的配置

关闭防火墙和Linux

[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0

 下载DNS

[root@localhost ~]# dnf install bind -y

从服务器配置


options {
        listen-on port 53 { 192.168.108.130; };
        directory "/var/named/slaves";
        allow-query { any; };
};

zone "openlab.com" IN {
        type slave;
        file "named.openlab.com";
        masters {192.168.108.129; };
};

zone "108.168.192.in-addr.arpa" IN {
         type slave;
         file "named.192";
         masters { 192.168.108.129; };
};

 主服务器正反向解析

[root@localhost ~]# nslookup
> server 192.168.108.129
Default server: 192.168.108.129
Address: 192.168.108.129#53

> ns.openlab.com
Server:        192.168.108.129
Address:    192.168.108.129#53

Name:    ns.openlab.com
Address: 192.168.108.129
> 192.168.108.129
129.108.168.192.in-addr.arpa    name = ns.openlab.com.

三,完全区域传送 

主服务器

$TTL 1D
@       IN      SOA     @       lxx.qq.com. ( 
                                        2024110100
                                        1D
                                        1H
                                        5H
                                        1D
)
        IN      NS      ns.openlab.com.
ns      IN      A       192.168.108.129
slave   IN      A       192.168.108.130


www     IN      A       192.168.108.128
ftp     IN      A       192.168.108.139
mail    IN      A       192.168.108.140
wwww    IN      CNAME   www
wwwww   IN      CNAME   www

从服务器

 [root@localhost ~]# ll /var/named/slaves
total 16
-rw-r--r--. 1 named named  821 Nov  1 22:16 managed-keys.bind
-rw-r--r--. 1 named named 3733 Nov  1 22:16 managed-keys.bind.jnl
-rw-r--r--. 1 named named  463 Nov  1 21:52 named.192
-rw-r--r--. 1 named named  384 Nov  1 21:52 named.openlab.com

四,增量区域传送

主服务器

$TTL 1D
@       IN      SOA     @       lxx.qq.com. ( 
                                        2024110100
                                        1D
                                        1H
                                        5H
                                        1D
)
        IN      NS      ns.openlab.com.
        IN      NS      slave.openlab.com.
ns      IN      A       192.168.108.129
slave   IN      A       192.168.108.130


www     IN      A       192.168.108.128
ftp     IN      A       192.168.108.139
mail    IN      A       192.168.108.140
wwww    IN      CNAME   www
wwwww   IN      CNAME   www
 

 

从服务器

 [root@localhost ~]# tail -f /var/log/messages
Nov  1 22:23:57 localhost systemd[1]: Started Network Manager Script Dispatcher Service.
Nov  1 22:24:07 localhost systemd[1]: NetworkManager-dispatcher.service: Deactivated successfully.
Nov  1 22:37:01 localhost named[41618]: client @0x7f2924057a98 192.168.85.136#46600: received notify for zone 'openlab.com'
Nov  1 22:37:01 localhost named[41618]: zone openlab.com/IN: notify from 192.168.85.136#46600: serial 2024110101
Nov  1 22:37:01 localhost named[41618]: zone openlab.com/IN: Transfer started.
Nov  1 22:37:01 localhost named[41618]: transfer of 'openlab.com/IN' from 192.168.85.136#53: connected using 192.168.85.135#45691
Nov  1 22:37:01 localhost named[41618]: zone openlab.com/IN: transferred serial 2024110101
Nov  1 22:37:01 localhost named[41618]: transfer of 'openlab.com/IN' from 192.168.85.136#53: Transfer status: success
Nov  1 22:37:01 localhost named[41618]: transfer of 'openlab.com/IN' from 192.168.85.136#53: Transfer completed: 1 messages, 11 records, 280 bytes, 0.001 secs (280000 bytes/sec) (serial 2024110101)
Nov  1 22:37:01 localhost named[41618]: zone openlab.com/IN: sending notifies

[root@localhost ~]# nslookup 
> server 192.168.108.130
Default server: 192.168.108.130
Address: 192.168.108.130#53
> slave.openlab.com
Server:        192.168.108.130
Address:    192.168.108.130#53
 
Name:    slave.openlab.com
Address: 192.168.108.130
> wwwww.openlab.com
Server:        192.168.108.130
Address:    192.168.108.130#53
 
wwwww.openlab.com    canonical name = www.openlab.com.
Name:    www.openlab.com
Address: 192.168.108.128

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值