主从服务器配置:
(1)完全区域传送:复制整个区域文件
#主DNS服务器的配置【主dns服务器的ip地址为192.168.168.129】
#编辑DNS系统配置信息(我这里写的增加的信息,源文件里面有很多内容)
[root@localhost ~]# vim /etc/named.conf
options {
listen-on port 53 { 192.168.168.129; };
directory "/var/named";
allow-transfer { 192.168.168.137; }; #从服务器地址
};
#正解析区域
zone "baidu.com" IN {
type master;
file "baidu";
};#反解析区域
#例如IP为192.168.168.129,这里就要写16.168.192.in-addr.arpa(反过来写)
zone "168.168.192.in-addr.arpa" IN {
type master;
file "named.192.168.168";
};#编辑正向解析配置文件
[root@localhost ~]# vim /var/named/baidu
$TTL 1D
@ IN SOA @ admin.admin.com. ( 2024011400 1D 1H 3H 1D )
IN NS dns.baidu.com.
dns IN A 192.168.168.129
www IN A 192.168.168.111
ftp IN A 192.168.168.123
a IN A 192.168.168.100
aaa IN CNAME a
#重启服务
[root@localhost ~]# systemct restart named
#从DNS服务器的配置【从dns服务器的ip地址为192.168.168.137】
#安装DNS对应工具
[root@localhost ~]# yum install bind -y
#编辑DNS系统配置文件
[root@localhost ~]# vim /etc/named.conf
options {
listen-on port 53 { 192.168.168.129; };
directory "/var/named";
};
zone "baidu.com" IN {
type slave;
file "slaves/named.baidu.com";
masters {192.168.168.129;};
};
#重启服务
[root@localhost ~]# systemct restart named
#测试(从服务器上)
[root@localhost ~]# nslookup
>server 192.168.168.129
> 192.168.168.100
100.168.168.192.in-addr.arpa name = a.baidu.com.
> 192.168.168.111
111.168.168.192.in-addr.arpa name = www.baidu.com.
>
#正向反向解析成功
#查看从服务器获取主服务器的解析文件(是乱码)
[root@192 ~]# cat /var/named/slaves/baidu
e▒▒QQ▒
baiducom0baiducomadminadmincomx▒▒Q▒*0Q▒0Q▒
abaiducom)Q▒dnsbaiducom▒▒▒)Q▒ftpbaiducom▒▒{)Q▒wwwbaiducom▒▒o[root@192 ~]# xterm-256colorxterm-xterm-256colorxterm-256colorxterm-256colorxterm-256colorxterm-256colorxterm-256colorxterm-256colorxterm-256colorxterm-256colorxterm-256colorxt
erm-256colorxterm-256colorxterm-256color
(2)增量区域传送:仅复制区域里变化的文件
#修改主服务器的区域配置文件,序号比之前的序号大【注:区域文件里面必须要写从服务器的NS和A记录】
#增加主DNS服务器的配置【主dns服务器的ip地址为192.168.168.129】
#增加内容
[root@localhost ~]# vim /var/named/baidu
$TTL 1D
@ IN SOA @ admin.admin.com. ( 2024011400 1D 1H 3H 1D )
IN NS dns.baidu.com.
dns IN A 192.168.168.129
www IN A 192.168.168.111
ftp IN A 192.168.168.123
a IN A 192.168.168.100
aaa IN CNAME a
bbb IN CNAME www(增加的解析)
[root@localhost ~]#vim /var/named/named.192.168.168
$TTL 1D
@ IN SOA @ admin.admin.com. ( 2024011400 1D 1H 3H 1D )
IN NS dns.baidu.com.
129 IN PTR dns.baidu.com.
111 IN PTR www.baidu.com.
123 IN PTR ftp.baidu.com.
100 IN PTR a.baidu.com.
a IN CNAME aaa
www IN CNAME bbb(增加的解析)#重启服务
[root@localhost ~]# systemct restart named
#从服务器验证:
#重启服务
[root@localhost ~]# systemct restart named
[root@192 ~]# nslookup
> server 192.168.168.129
Default server: 192.168.168.129
Address: 192.168.168.129#53
> bbb.baidu.com
Server: 192.168.168.129
Address: 192.168.168.129#53
bbb.baidu.com canonical name = www.baidu.com.
Name: www.baidu.com
Address: 192.168.168.111
>
这里可以以看到正向反向解析都能够实现,实验就完成了
补充:
#查看从服务器是否监听成功(可以看见时间一直在更新)
[root@192 ~]# watch /var/named/slaves/