主从DNS的环境应用:1、负载均衡,缓解主DNS压力。
2、当主DNS挂了,DNS会正常工作、不会影响正常工作。
3、可以更快的相应客户的请求。
环境:拥有2台服务器,分别配置静态IP和安装rpm包
主DNS(rh_2):
[[email protected]_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 [[email protected]_2 ~]# yum -y install bind bind-chroot caching-nameserver
从DNS(rh—3)
[[email protected]_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 [[email protected]_3 ~]# yum -y install bind bind-chroot caching-nameserver
一:配置主DNS
1、编辑主配置文件
[[email protected]_2 ~]# cd /var/named/chroot/etc/ [[email protected]_2 etc]# cp -p named.caching-nameserver.conf named.conf [[email protected]_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数据文件
[[email protected]_2 etc]# vim named.rfc1912.zones [[email protected]_2 etc]# cat named.rfc1912.zones | tail -4 zone "baidu.com" IN { type master; file "baidu.zone"; };
3、编辑本地区域数据文件
[[email protected]_2 etc]# cd /var/named/chroot/var/named/ [[email protected]_2 named]# cp -p named.local baidu.zone [[email protected]_2 named]# vim baidu.zone [[email protected]_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服务
[[email protected]_2 named]# service named restart [[email protected]_2 named]# chkconfig named on
二、配置从DNS
1、配置DNS主配置文件
[[email protected]_3 ~]# cd /var/named/chroot/etc/ [[email protected]_3 etc]# cp -p named.caching-nameserver.conf named.conf [[email protected]_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数据文件
[[email protected]_3 etc]# vim named.rfc1912.zones [[email protected]_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 }; [[email protected]_3 etc]# service named restart [[email protected]_3 etc]# chkconfig named on [[email protected]_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. ......
时间: 2024-10-13 11:36:10