BIND(Berkeley Internet Name Domain) 是一种广泛使用的 DNS 服务器软件,它具有高可配置性和扩展性。在 BIND 中,DNS 服务可以分为主服务器(Primary DNS Server)和辅助服务器(Secondary DNS Server)。辅助 DNS 服务器也被称为从服务器(Slave DNS Server),它们通过从主服务器同步数据来提供冗余和高可用性。
辅助 DNS 服务器的主要功能
数据冗余和高可用性:辅助服务器从主服务器获取区域数据(zone data),确保当主服务器不可用时,DNS 查询依然能够得到响应。这提高了整个 DNS 系统的可靠性和可用性。
负载均衡:通过分散 DNS 查询负载到多个服务器,辅助服务器有助于减轻主服务器的负载,提升服务响应速度。
防止单点故障:辅助服务器可以在主服务器发生故障时接管 DNS 服务,避免单点故障导致的服务中断。
数据同步:辅助服务器定期与主服务器同步数据,确保辅助服务器上的 DNS 记录与主服务器保持一致。这种同步通常通过 zone transfer(区域传输)来实现,常见的方式有全量传输(AXFR)和增量传输(IXFR)。
zone "lixiaohui.cn" IN { type slave; file "slaves/lixiaohui.cn.zone"; masters { 172.25.250.10; }; }; zone "250.25.172.in-addr.arpa" IN { type slave; file "slaves/lixiaohui.cn.ptr"; masters { 172.25.250.10; }; };
Aug 23 01:01:51 serverb.lab.example.com named[26633]: zone lixiaohui.cn/IN: Transfer started. Aug 23 01:01:51 serverb.lab.example.com named[26633]: transfer of 'lixiaohui.cn/IN' from 172.25.250.10#53: connected using 172.25.250.11#52091 Aug 23 01:01:51 serverb.lab.example.com named[26633]: zone lixiaohui.cn/IN: transferred serial 1 Aug 23 01:01:51 serverb.lab.example.com named[26633]: transfer of 'lixiaohui.cn/IN' from 172.25.250.10#53: Transfer status: success Aug 23 01:01:51 serverb.lab.example.com named[26633]: transfer of 'lixiaohui.cn/IN' from 172.25.250.10#53: Transfer completed: 1 messages, 9 records, 281 bytes, 0.002 secs (140500 bytes/sec) Aug 23 01:01:51 serverb.lab.example.com named[26633]: zone 250.25.172.in-addr.arpa/IN: Transfer started. Aug 23 01:01:51 serverb.lab.example.com named[26633]: transfer of '250.25.172.in-addr.arpa/IN' from 172.25.250.10#53: connected using 172.25.250.11#33001 Aug 23 01:01:51 serverb.lab.example.com named[26633]: zone 250.25.172.in-addr.arpa/IN: transferred serial 1 Aug 23 01:01:51 serverb.lab.example.com named[26633]: transfer of '250.25.172.in-addr.arpa/IN' from 172.25.250.10#53: Transfer status: success Aug 23 01:01:51 serverb.lab.example.com named[26633]: transfer of '250.25.172.in-addr.arpa/IN' from 172.25.250.10#53: Transfer completed: 1 messages, 5 records, 197 bytes, 0.001 secs (197000 bytes/sec) Aug 23 01:02:01 serverb.lab.example.com named[26633]: resolver priming query complete
查询辅助DNS服务器
1 2 3 4
[root@serverb ~]# ll /var/named/slaves/ total 8 -rw-r--r--. 1 named named 326 Aug 23 01:01 lixiaohui.cn.ptr -rw-r--r--. 1 named named 480 Aug 23 01:01 lixiaohui.cn.zone
[root@servera ~]# cd /var/named/ [root@servera named]# vim lixiaohui.cn.zone [root@servera named]# cat lixiaohui.cn.zone $TTL 1D lixiaohui.cn. IN SOA ns.lixiaohui.cn. 939958092.qq.com. ( 2 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum 1D IN NS ns.lixiaohui.cn. ns 1D IN A 172.25.250.10 lxh 30 IN A 192.168.8.100 lxh-2 30 IN A 192.168.8.100 30 IN AAAA 2001:db8:2020::5300 @ 20 IN MX 10 mail.lixiaohui.cn. mail 30 IN A 172.25.250.10 support.online 1H IN A 172.25.250.10
[root@serverb ~]# cd /var/named/slaves/ [root@serverb slaves]# cat lixiaohui.cn.zone $ORIGIN . $TTL 86400 ; 1 day lixiaohui.cn IN SOA ns.lixiaohui.cn. 939958092.qq.com. ( 2 ; serial 86400 ; refresh (1 day) 3600 ; retry (1 hour) 604800 ; expire (1 week) 10800 ; minimum (3 hours) ) NS ns.lixiaohui.cn. $TTL 20 ; 20 seconds MX 10 mail.lixiaohui.cn. $ORIGIN lixiaohui.cn. $TTL 30 ; 30 seconds lxh A 192.168.8.100 lxh-2 A 192.168.8.100 AAAA 2001:db8:2020::5300 mail A 172.25.250.10 $TTL 86400 ; 1 day ns A 172.25.250.10 $TTL 3600 ; 1 hour support.online A 172.25.250.10
确认日志消息正确
1 2 3 4 5 6 7
Aug 23 04:05:50 serverb.lab.example.com named[864]: client @0x7fe308044c90 172.25.250.10#53572: received notify for zone 'lixiaohui.cn' Aug 23 04:05:50 serverb.lab.example.com named[864]: zone lixiaohui.cn/IN: notify from 172.25.250.10#53572: serial 2 Aug 23 04:05:50 serverb.lab.example.com named[864]: zone lixiaohui.cn/IN: Transfer started. Aug 23 04:05:50 serverb.lab.example.com named[864]: transfer of 'lixiaohui.cn/IN' from 172.25.250.10#53: connected using 172.25.250.11#46605 Aug 23 04:05:50 serverb.lab.example.com named[864]: zone lixiaohui.cn/IN: transferred serial 2 Aug 23 04:05:50 serverb.lab.example.com named[864]: transfer of 'lixiaohui.cn/IN' from 172.25.250.10#53: Transfer status: success Aug 23 04:05:50 serverb.lab.example.com named[864]: transfer of 'lixiaohui.cn/IN' from 172.25.250.10#53: Transfer completed: 1 messages, 10 records, 289 bytes, 0.001 secs (289000 bytes/sec)