BIND的主从复制以及子域授权:
主从复制:
1、应该为一台独立的名称服务器;
2、主服务器的区域解析库文件中必须有一条NS记录是指向从服务器;
3、从服务器只需要定义区域,而无须提供解析库文件;解析库文件应该放置于/var/named/slaves/目录中;
4、主服务器得允许从服务器作区域传送;
5、主从服务器时间应该同步,可通过ntp进行;
6、bind程序的版本应该保持一致;否则,应该从高,主低;
测试环境:centos6.6 主NDS 辅助DNS 子域DNS server server2 centos6
配置辅助DNS的主配置文件:
[root@server2 slaves]# vim /etc/named.conf zone "yangbb123.com." IN { type slave; masters { 192.168.1.121; }; file "slaves/yangbb123.com.zone"; }; zone "1.168.192.in-addr.arpa" IN { type slave; masters { 192.168.1.121; }; file "slaves/192.168.1.zone"; };
创建区域文件:
[root@server2 slaves]# ll /var/named/slaves/ total 8 -rw-r--r-- 1 named named 489 Sep 27 09:32 192.168.1.zone -rw-r--r-- 1 named named 640 Sep 27 09:02 yangbb123.com.zone
重启主DNS #services named reload
[root@server named]#tail /val/log/message Sep 27 04:50:31 server named[50236]: reloading configuration succeeded Sep 27 04:50:31 server named[50236]: reloading zones succeeded Sep 27 04:50:41 server named[50236]: client 192.168.1.121#55547: zone transfer 'yangbb123.com/AXFR/IN' denied Sep 27 04:50:56 server named[50236]: client 192.168.1.121#45158: zone transfer 'yangbb123.com/AXFR/IN' denied Sep 27 04:51:11 server named[50236]: client 192.168.1.121#46448: zone transfer 'yangbb123.com/AXFR/IN' denied Sep 27 04:51:18 server named[50236]: client 192.168.1.122#51911: transfer of 'yangbb123.com/IN': AXFR started Sep 27 04:51:18 server named[50236]: client 192.168.1.122#51911: transfer of 'yangbb123.com/IN': AXFR ended
查看从辅助DNS的区域配置文件是否数据传输过来:
[root@server2 slaves]# cat yangbb123.com.zone $ORIGIN . $TTL 86400 ; 1 day yangbb123.com IN SOA ns1.yangbb123.com. admin.yangbb123.com. ( 2015092604 ; serial 7200 ; refresh (2 hours) 300 ; retry (5 minutes) 172800 ; expire (2 days) 86400 ; minimum (1 day) ) NS ns1.yangbb123.com. NS ns2.yangbb123.com. MX 10 mail.yangbb123.com. $ORIGIN yangbb123.com. ftp A 192.168.1.121 img A 192.168.1.124 mail A 192.168.1.121 ns1 A 192.168.1.121 ns2 A 192.168.1.122
root@server2 slaves]# cat 192.168.1.zone $ORIGIN . $TTL 600 ; 10 minutes 1.168.192.in-addr.arpa IN SOA ns1.yangbb123.com. admin.yangbb123.com. ( 2015092601 ; serial 7200 ; refresh (2 hours) 300 ; retry (5 minutes) 172800 ; expire (2 days) 172800 ; minimum (2 days) ) NS ns1.yangbb123.com. NS ns2.yangbb123.com. $ORIGIN 1.168.192.in-addr.arpa. 121 PTR ns1.yangbb123.com. PTR www.yangbb123.com. PTR mmai.yangbb123.com PTR ftp.yangbb123.com. 122 PTR ns2.yangbb123.com.
[root@server2 slaves]# dig -t A www.yangbb123.com @192.168.1.122 #依然能正常解析 ; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6_7.4 <<>> -t A www.yangbb123.com @192.168.1.122 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52959 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 2, ADDITIONAL: 2 ;; QUESTION SECTION: ;www.yangbb123.com. IN A ;; ANSWER SECTION: www.yangbb123.com. 86400 IN A 192.168.1.122 www.yangbb123.com. 86400 IN A 192.168.1.123 www.yangbb123.com. 86400 IN A 192.168.1.121 ;; AUTHORITY SECTION: yangbb123.com. 86400 IN NS ns2.yangbb123.com. yangbb123.com. 86400 IN NS ns1.yangbb123.com.
注:1 主dns里面需要有辅助DNS的DNS记录,已经辅助DNS的主机名
2 主DNS有数据更新,需给序列号加1
子域授权:
在子域DNS的主配置文件添加:
zone "tech.yangbb123.com" { type master; file "tech.yangbb123.com.zone"; };
添加区域文件:
[root@centos6 named]# ll /var/log/messages [root@centos6 named]# ll /var/named/tech.yangbb123.com.zone 编辑区域文件: $TTL 1D @ IN SOA dns.tech.yangbb123.com. admin.tech.yangb123.com. ( 2015092601 2H 5M 2D 1D ) @ IN NS dns @ IN MX 10 mail dns IN A 192.168.1.112 mail IN A 192.168.1.112 www IN A 192.168.1.112
在主DNS里面添加如下记录:
tech IN NS dns.tech.yangbb123.com. dns.tech.yangbb123.com. IN A 192.168.1.112
测试:
[root@server named]# dig -t NS tech.yangbb123.com @192.168.1.112 #主DNS测试: ; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6_7.4 <<>> -t NS tech.yangbb123.com @192.168.1.121 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43241 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; QUESTION SECTION: ;tech.yangbb123.com. IN NS ;; ANSWER SECTION: tech.yangbb123.com. 600 IN NS dns.tech.yangbb123.com. ;; ADDITIONAL SECTION: dns.tech.yangbb123.com. 600 IN A 192.168.1.112
子域dns测试:
dig -t NS tech.yangbb123.com @192.168.1.112 ; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6_7.4 <<>> -t NS tech.yangbb123.com @192.168.1.112 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64499 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; QUESTION SECTION: ;tech.yangbb123.com. IN NS ;; ANSWER SECTION: tech.yangbb123.com. 600 IN NS dns.tech.yangbb123.com. ;; ADDITIONAL SECTION: dns.tech.yangbb123.com. 600 IN A 192.168.1.112
子域授权完成!!!