实验环境: Red Hat Enterprise Linux Server 5.4
DNS服务器IP:192.168.0.10
缓存DNS服务器IP:192.168.0.20
客户端IP:192.168.0.30
1、在两台服务器中安装BIND软件包
bind-9.3.6-4.P1.el5.i386.rpm
bind-9.3.6-4.P1.el5.i386.rpm
bind-utils-9.3.6-4.P1.el5.i386.rpm
caching-nameserver-9.3.6-4.P1.el5.i386.rpm
2、构建主DNS服务器
1) 配置全局配置文件named.conf
#cd /var/named/chroot/etc
#cp –p named.caching.nameserver.conf named.conf //-p 保持原权限
#vim named.conf
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
allow-query { any; };
allow-query-cache { any; };
};
logging {
};
view localhost_resolver {
match-clients { any; };
match-destinations { any; };
recursion yes;
include "/etc/named.rfc1912.zones";
};
2) 配置区域配置文件
#vim named.rfc1912.zones //复制21到31行,粘贴最后面
…………………
zone "crazylinux.com" IN {
type master;
file "c.zheng";
allow-update { none; };
};
zone "0.168.192.in-addr.arpa" IN {
type master;
file "c.fan";
allow-update { none; };
};
3) 配置正向解析区域数据库文件
#cd ../var/named
#cp -p named.zero c.zheng
#vim c.zheng
$TTL 86400
@ IN SOA localhost. root.localhost. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
D ) ; minimum
IN NS dns.crazylinux.com.
dns IN A 192.168.0.10
mail IN MX 5 mail.crazylinux.com.
www IN A 192.168.0.100
mail IN A 192.168.0.200
* IN A 192.168.0.100 //泛域名解析
@ IN A 192.168.0.100 //可以无主机头
love IN CNAME mail //别名
注意:NS域名服务器记录
MX (1-10) 邮件交换记录
A 地址记录
CNAME 别名记录
4) 配置反向解析区域数据库文件
#cp -p c.zheng c.fan
$TTL 86400
@ IN SOA localhost. root.localhost. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
D ) ; minimum
IN NS dns.crazylinux.com.
10 IN PTR dns.crazylinux.com.
mail IN MX 5 mail.crazylinux.com.
100 IN PTR www.crazylinux.com.
200 IN PTR mail.crazylinux.com.
love IN CNAME mail
#service named restart 重启服务
#chkconfig named on
5) 设置客户端DNS:192.168.0.10 进行测试(主DNS服务器IP)
3、 在缓存域名服务器上配置缓存+转发
1) 配置全局配置文件named.conf
#cd /var/named/chroot/etc
#cp –p named.caching.nameserver.conf named.conf //-p 保持原权限
#vim named.conf
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db"; //设置域名缓存数据库文件位置
……………
forwarders { 192.168.0.10; }; //缓存服务器无法解析,转发给主DNS
allow-query { any; };
allow-query-cache { any; };
};
logging {
};
view localhost_resolver {
match-clients { any; };
match-destinations { any; };
recursion yes;
include "/etc/named.rfc1912.zones";
};
#service named restart 重启named 服务
#chkconfig named on
2) 设置客户端DNS:192.168.0.20 进行测试(缓存域名服务器IP)
4、在主DNS上设置负载均衡
修改正向解析区域数据库文件
#cd ../var/named
#cp -p named.zero c.zheng
#vim c.zheng
$TTL 86400
@ IN SOA localhost. root.localhost. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
D ) ; minimum
IN NS dns.crazylinux.com.
dns IN A 192.168.0.10
mail IN MX 5 mail.crazylinux.com.
www IN A 192.168.0.100
www IN A 192.168.0.101
www IN A 192.168.0.102
mail IN A 192.168.0.200
* IN A 192.168.0.100 //泛域名解析
@ IN A 192.168.0.100 //访问可以省略主机头
love IN CNAME mail //别名
注意:NS域名服务器记录
MX (1-10) 邮件交换记录
A 地址记录
CNAME 别名记录
3) 修改反向解析区域数据库文件
#cp -p c.zheng c.fan
$TTL 86400
@ IN SOA localhost. root.localhost. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
D ) ; minimum
IN NS dns.crazylinux.com.
10 IN PTR dns.crazylinux.com.
mail IN MX 5 mail.crazylinux.com.
100 IN PTR www.crazylinux.com.
101 IN PTR www.crazylinux.com.
102 IN PTR www.crazylinux.com.
200 IN PTR mail.crazylinux.com.
love IN CNAME mail
#service named restart 重启服务
5) 设置缓存域名服务器DNS:192.168.0.10 进行测试(主DNS服务器IP)