bind-9.3.6-4.P1.el5.i386.rpm,bind-libs-9.3.64.P1.el5.i386.rpm
bind-utils-9.3.6-4.P1.el5.i386.rpm,caching-nameserver-9.3.6-4.P1.el5.i386.rpm bind-devel-9.3.6-4.P1.el5.i386.rpm,bind-chroot-9.3.6-4.P1.el5.i386.rpm
2.redhat5中主配置文件named.conf由named.caching-nameserver.conf和 named.rfc1912.zones两个文件来代替
1)修改named.caching-nameserver.conf为:
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
query-source port 53;
query-source-v6 port 53;
allow-query { any; };
forwarders { 210.22.84.3; };
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
view localhost_resolver {
match-clients { any; };
match-destinations { any; };
recursion yes;
include "/etc/named.rfc1912.zones";
};
就是把所有的localhost修改为any,默认dns只对本机开启,然后再
options字段中添加forwarders字段,也就是设置dns转发。
2)修改named.rfc1912.zones配置文件,在末尾添加:
zone "test.com" IN {
type master;
file "test.com.zone";
allow-update { 192.168.10.219; }; //允许从域名服务器更新
};
zone "10.168.192.in-addr.arpa" IN {
type master;
file "192.168.10.rev";
allow-update { 192.168.10.219; }; //允许从域名服务器更新
};
设置要建立的区域,这里假设我要建立两个DNS服务器互为备份,主服务器为192.168.10.217,从服务器为192.168.10.219
3.创建区域文件
区域文件保存在/var/named/chroot/var/named/目录下面,cp localhost.zone test.com.zone,编辑test.com.zone完整内容如下
$TTL 86400
@ IN SOA master.test.com. root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS @
IN A 127.0.0.1
IN AAAA ::1
@ IN NS master.test.com.
host1 IN A 192.168.10.101
host2 IN A 192.168.10.102
host3 IN A 192.168.10.219
master IN A 192.168.10.217
@ IN MX 10 mail.test.com.
mail IN CNAME host3
www IN CNAME host2
ftp IN CNAME host1
然后建立反向区域文件cp test.com.zone 192.168.10.rev,编辑192.168.10.rev如下:
$TTL 86400
@ IN SOA master.test.com. root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS @
IN A 127.0.0.1
IN AAAA ::1
@ IN NS master.test.com.
101 IN PTR host1.test.com.
102 IN PTR host2.test.com.
219 IN PTR host3.test.com.
217 IN PTR master.test.com.
注意:最后一定要设置权限让named用户拥有所有权 chown named:named test.com.zone 192.168.10.rev
4.测试
1)使用named-checkconf可以对named.conf配置文件的语法进行测试,若配置文件正确则没有任何输出信息
2)使用named-checkzone可以对DNS区域文件的语法进行测试
[root@test etc]# named-checkzone test.com /var/named/chroot/var/named/test.com.zone
zone test.com/IN: loaded serial 42
OK
[root@test etc]# named-checkzone 10.168.192.in-addr.arpa /var/named/chroot/var/named/192.168.10.rev
zone 10.168.192.in-addr.arpa/IN: loaded serial 42
OK
5.构建从域名服务器可以确保DNS的可靠,从域名服务器需要安装bind-9.3.6-4.P1.el5.i386.rpm,和caching-nameserver-9.3.6-4.P1.el5.i386.rpm两个软件包,配置方法和主域名服务器基本相同,添加区域:
zone "test.com" IN {
type slave;
file "salves/test.com.zone";
masters { 192.168.10.217; }; //从主域名服务器更新
};
zone "10.168.192.in-addr.arpa" IN {
type slave;
file "salves/192.168.10.rev";
masters { 192.168.10.217; }; //从主域名服务器更新
};
之后启动服务就会看到salves目录下面已经有了从主服务器上同步过来的区域文件了。
注:redhat5中从服务器上面区域文件默认是放在salves目录下面的,如果这里你选择一个自己设置的目录在selinux环境下会同步失败,这时候就需要打开selinux里面的相关设置,允许使用其他目录存放同步的区域文件就可以了。
6.使用nslookup/host/dig命令对域名服务器进行测试,具体测试参见nslookup命令帮助
7.可以使用rndc来管理dns服务器,默认系统已经安装了
1)rndc status 显示DNS服务器的状态信息
2)rndc stats 记录DNS的统计数据,默认会在/var/named/chroot/var/named/data/目录内产生新文件
3)rndc dumpdb 记录DNS的高速缓存,默认存放在/var/named/chroot/var/named/data/cashe_dump.db文件中