DNF 主从服务器的搭建
1,主服务器的配置
-
关闭防火墙和Linux的安全程序
[root@localhost ~]# systemctl stop firewalld.service #关闭防火墙
[root@localhost ~]# setenforce 0 #关闭安全策略
-
下载DNS
[root@localhost ~]# dnf install bind -y
-
配置操作
[root@localhost ~]# vim /etc/named.conf
options{
listen-on port 53 { 192.168.85.136; };
directory "/var/named";
allow-query { any; };
allow-transfer { 192.168.85.135; };
};
zone "openlab.com" IN {
type master;
file "named.openlab.com";
};
zone "85.168.192.in-addr.arpa" IN {
type master;
file "named.192";
allow-update { none; };
};
2,从服务器的配置
-
关闭防火墙和Linux的安全程序
[root@localhost ~]# systemctl stop firewalld.service #关闭防火墙
[root@localhost ~]# setenforce 0 #关闭安全策略
-
下载DNS
[root@localhost ~]# dnf install bind -y
-
配置操作
options{
listen-on port 53 { 192.168.85.135; };
directory "/var/named/slaves";
allow-query { any; };
};
zone "openlab.com" IN {
type slave;
file "named.openlab.com";
masters { 192.168.85.136; };
};
zone "85.168.192.in-addr.arpa" IN {
type slave;
file "named.192";
masters { 192.168.85.136; };
};
3,完全区域传送
-
主服务器:
[root@localhost ~]# vim /var/named/named.openlab.com
$TTL 1D
@ IN SOA @ lxx.qq.com. (
2024110100
1D
1H
5H
1D
)
IN NS ns.openlab.com.
ns IN A 192.168.85.136
www IN A 172.25.250.111
ftp IN A 172.25.250.100
mail IN A 172.25.250.132
wwww IN CNAME www
[root@localhost ~]# systemctl restart named
-
从服务器:
[root@localhost ~]# systemctl restart named
[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
4,增量区域传送
-
主服务器:
[root@localhost ~]# vim /var/named/named.openlab.com
$TTL 1D
@ IN SOA @ lxx.qq.com. (
2024110101
1M
1M
1M
1M
)
IN NS ns.openlab.com.
IN NS slave.openlab.com.
ns IN A 192.168.85.136
slave IN A 192.168.85.135
www IN A 172.25.250.111
ftp IN A 172.25.250.100
mail IN A 172.25.250.132
wwww IN CNAME www
wwwww IN CNAME www
[root@localhost ~]# systemctl restart named
-
从服务器:
[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 (serial 2024110101)
[root@localhost ~]# nslookup
> server 192.168.85.135
Default server: 192.168.85.135
Address: 192.168.85.135#53
> slave.openlab.com
Server: 192.168.85.135
Address: 192.168.85.135#53
Name: slave.openlab.com
Address: 192.168.85.135
> wwwww.openlab.com
Server: 192.168.85.135
Address: 192.168.85.135#53
wwwww.openlab.com canonical name = www.openlab.com.
Name: www.openlab.com
Address: 172.25.250.111