主从DNS服务搭建
在基础环境下再添加一台从服务器centos6 ip:172.16.1.30
主服务器配置
在服务器配置的基础上修改区域配置文件 其他配置不变
vim /etc/named.rfc1912.zones
zone "qy.vip" IN {
type master;
file "qy.localhoost";
allow-transfer { 172.16.1.30; }; #从服务器ip
};
zone "1.16.172.in-addr.arpa" IN {
type master;
file "qy.loopback";
allow-transfer { 172.16.1.30; }; #从服务器ip
};
重启DNS服务
systemctl restart named
从服务器配置
yum -y install bind
vim /etc/named.conf #编辑配置文件
vim /etc/named.rfc1912.zones
zone "qy.vip" IN { #正向区域
type slave; #类型 从
masters { 172.16.1.10; }; #主DNS服务器ip
file "slaves/qy.vip.localhost";
};
zone "1.16.172.in-addr.arpa" IN { #反向区域
type slave;
masters { 172.16.1.10; }; #主DNS服务器ip
file "slaves/qy.vip.loopback";
};
#无需配置数据文件,启动服务会自动从主服务器同步到指定文件中
启动DNS服务
service named start
查看是否数据同步
测试机配置
修改网卡配置,添加DNS1=从服务器ip
vim /etc/sysconfig/network-scripts/ifcfg-ens33
重启网络服务
service network restart
使用nslookup测试
[root@zcy02 ~]# nslookup dns.qy.vip
Server: 172.16.1.30
Address: 172.16.1.30#53
Name: dns.qy.vip
Address: 172.16.1.10
[root@zcy02 ~]# nslookup www.qy.vip
Server: 172.16.1.30
Address: 172.16.1.30#53
Name: www.qy.vip
Address: 172.16.1.10
[root@zcy02 ~]# nslookup 172.16.1.10
Server: 172.16.1.30
Address: 172.16.1.30#53
10.1.16.172.in-addr.arpa name = www.qy.vip.
10.1.16.172.in-addr.arpa name = dns.qy.vip.
[root@zcy02 ~]#
实践成功
设置主从服务器的实时同步
在主DNS服务上添加实时同步的设置
vim /etc/named.rfc1912.zones
zone "qy.vip" IN {
type master;
file "Zqy.vip";
allow-update { 172.16.1.20; };
allow-transfer { 172.16.1.20; };
also-notify { 172.16.1.20; };
};
zone "1.16.172.in-addr.arpa" IN {
type master;
file "Fqy.vip";
allow-update { 172.16.1.20; };
allow-transfer { 172.16.1.20; };
also-notify { 172.16.1.20; };
};
在主DNS服务上更改正向数据配置文件
systemctl restart named
测试 :在从服务器查看已同步
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/148973.html