DNS服务器主从同步:
首先同步时间:
在主域名服务器上:
yum install ntp -y
vi /etc/ntp.conf
restrict 192.168.80.0 mask 255.255.255.0 nomodify notrap
server 127.127.1.0
fudge 127.127.1.0 stratum 8
service ntpd start
systemctl enable ntpd
从域名服务器上:
yum install ntp -y
ntpdate 192.168.80.100
搭建主从同步:
在主域名服务器上:
vi /etc/named.conf
修改以下内容:
listen-on port 53 { any; };
allow-query { any; };
vi /etc/named.rfc1912.zones
zone “hello.com” IN {
type master;
file “hello.com.zone”;
allow-update { 192.168.80.101; };
also-notify { 192.168.80.101; };
};
zone “80.168.192.in-addr.arpa” IN {
type master;
file “hello.com.local”;
allow-update { 192.168.80.101; };
also-notify { 192.168.80.101; };
};
cd /var/named/
cp -p named.localhost hello.com.zone
vi hello.com.zone
$TTL 1D
@ IN SOA hello.com. 18013882536.qq.com (
1 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns.hello.com.
dns IN A 192.168.80.100
www IN A 192.168.80.101
ftp IN A 192.168.80.102
cp -p hello.com.zone hello.com.local
vi hello.com.local
$TTL 1D
@ IN SOA hello.com. 18013882536.qq.com (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns.hello.com.
100 IN PTR dns.hello.com.
101 IN PTR www.hello.com.
systemctl start named
在从域名服务器中:
vi /etc/named.conf
修改以下内容:
listen-on port 53 { any; };
allow-query { any; };
vi /etc/named.rfc1912.zones
zone “hello.com” IN {
type slave;
masters { 192.168.80.100; };
file “slaves/hello.com.zone”;
};
zone “80.168.192.in-addr.arpa” IN {
type slave;
masters { 192.168.80.100; };
file “slaves/hello.com.local”;
};
systemctl start named
cat hello.com.zone
注:如果从域名服务器同步过去的数据配置文件出现乱码,使用以下方法解决:
vi /etc/named.conf
masterfile-format text ;
测试能否实时同步:
在主域名服务器中添加新的解析记录,并更改序列号
查看从域名服务器是否实时同步该数据