主从DNS的环境应用:1、负载均衡,缓解主DNS压力。
2、当主DNS挂了,DNS会正常工作、不会影响正常工作。
3、可以更快的相应客户的请求。
环境:拥有2台服务器,分别配置静态IP和安装rpm包
主DNS(rh_2):
[root@rh_2 ~]# ifconfig | head -2 eth0 Link encap:Ethernet HWaddr 52:54:02:AC:DE:C4 inet addr:192.168.122.243 Bcast:192.168.122.255 Mask:255.255.255.0 [root@rh_2 ~]# yum -y install bind bind-chroot caching-nameserver
从DNS(rh—3)
[root@rh_3 ~]# ifconfig | head -2 eth0 Link encap:Ethernet HWaddr 52:54:03:AC:DE:C4 inet addr:192.168.122.3 Bcast:192.168.122.255 Mask:255.255.255.0 You have mail in /var/spool/mail/root [root@rh_3 ~]# yum -y install bind bind-chroot caching-nameserver
一:配置主DNS
1、编辑主配置文件
[root@rh_2 ~]# cd /var/named/chroot/etc/ [root@rh_2 etc]# cp -p named.caching-nameserver.conf named.conf [root@rh_2 etc]# vim named.conf 14 options { 15 listen-on port 53 { 192.168.122.243; }; //监听本机 192.168.122.243的NDS查询 16 listen-on-v6 port 53 { ::1; }; 21 allow-transfer { 192.168.122.3; }; //授权从DNS 27 allow-query { any; }; // 允许所有客户端查询 28 allow-query-cache { any; }; 37 match-clients { any; }; 38 match-destinations { any; };
2、编辑DNS数据文件
[root@rh_2 etc]# vim named.rfc1912.zones [root@rh_2 etc]# cat named.rfc1912.zones | tail -4 zone "baidu.com" IN { type master; file "baidu.zone"; };
3、编辑本地区域数据文件
[root@rh_2 etc]# cd /var/named/chroot/var/named/ [root@rh_2 named]# cp -p named.local baidu.zone [root@rh_2 named]# vim baidu.zone [root@rh_2 named]# cat baidu.zone $TTL86400 @ IN SOA baidu.com. root.baidu.com. ( 2014050101 ; Serial 28800 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Minimum IN NS dns1.baidu.com. IN NS dns2.baidu.com. dns2 IN A 192.168.122.3 dns1 IN A 192.168.122.243 www IN A 192.168.122.1 zhidao IN A 192.168.122.2
4、启用DNS服务
[root@rh_2 named]# service named restart [root@rh_2 named]# chkconfig named on
二、配置从DNS
1、配置DNS主配置文件
[root@rh_3 ~]# cd /var/named/chroot/etc/ [root@rh_3 etc]# cp -p named.caching-nameserver.conf named.conf [root@rh_3 etc]# vim named.conf 14 options { 15 listen-on port 53 { 192.168.122.3; }; 27 allow-query { any; }; 28 allow-query-cache { any; }; 37 match-clients { any; }; 38 match-destinations { any; };
2、编辑DNS数据文件
[root@rh_3 etc]# vim named.rfc1912.zones [root@rh_3 etc]# cat named.rfc1912.zones | tail -6 zone "baidu.com" IN { type slave; //类型为从从DNS file "slaves/baidu.zone"; //本地区域数据路径和名字 masters { 192.168.122.243;}; //权威主DNS }; [root@rh_3 etc]# service named restart [root@rh_3 etc]# chkconfig named on [root@rh_3 etc]# cat /var/named/chroot/var/named/slaves/baidu.zone $ORIGIN . //当搭建成功后"slaves"下会增加文 件,数据与主DNS区域属于一致 baidu.comIN SOAbaidu.com. root.baidu.com. ( 2014050101 ; serial 28800 ; refresh (8 hours) 14400 ; retry (4 hours) 3600000 ; expire (5 weeks 6 days 16 hours) 86400 ; minimum (1 day) ) NS dns1.baidu.com. $ORIG IN baidu.com. ......