1.利用bind搭建DNS服务器需要安装2个软件包
bind-9.3.3-10.el5
caching-nameserver-9.3.3-10.el5
利用rpm名称查看是否安装了这2个包。如果没安全请自行安装,rpm包在iso镜像中有。
rpm -qa |grep bind 查看bind软件包是否安装
rpm -qa |grep caching 查看caching软件包是否安装
rpm -ivh caching-nameserver-9.3.3-10.el5 安装caching软件包
rpm -ivh bind-9.3.3-10.el5 安装bind9软件包
2.安装完毕后,修改主配置文件
BIND软件不需要named.conf这个配置文件,代替它的是
named.caching-nameserver.conf和named.rfc1912.zones这两个文件,并且需要作如下操作
vi /etc/named.caching-nameserver.conf
修改下面两个句子
options {
listen-on port 53 { 192.168.13.39; }; (默认此处是127.0.0.1)
allow-query { any; }; (默认是localhost)
vi /etc/named.rfc1912.zones 添加正向区域和反向区域见绿色字体
// named.rfc1912.zones:
//
// Provided by Red Hat caching-nameserver package
//
// ISC BIND named zone configuration for zones recommended by
// RFC 1912 section 4.1 : localhost TLDs and address zones
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
zone "." IN {
type hint;
file "named.ca";
};
zone "localdomain" IN {
type master;
file "localdomain.zone";
allow-update { none; };
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {
type master;
file "named.ip6.local";
allow-update { none; };
};
zone "255.in-addr.arpa" IN {
type master;
file "named.broadcast";
allow-update { none; };
};
zone "0.in-addr.arpa" IN {
type master;
file "named.zero";
allow-update { none; };
};
zone "benet.com" IN {
type master;
file "test.zx";
allow-update { none; };
};
zone "13.168.192.in-addr.arpa" IN {
type master;
file "test.fx";
allow-update { none; };
};
3.配置正向区域文件和反向区域文件
通过参考localhost域的正反向区域文件创建区域文件
cd /var/named
cp -p localdomain.zone /var/named/test.zx
cp -p named.local /var/named/test.fx
正向区域文件内容如下
$TTL 86400
@ IN SOA ns1.benet.com. root.benet.com. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS ns1.benet.com.
ns1 IN A 192.168.13.39
反向区域文件内容如下
$TTL 86400
@ IN SOA ns1.benet.com. root.benet.com. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS ns1.benet.com.
39 IN PTR ns1.benet.com.
4.配置完成后,重启named服务
service named restart
[root@localhost named]# service named restart
Stopping named: [ OK ]
Starting named: [ OK ]
5.修改resolv.conf 并添加test.zx 和 test.fx文件权限为644
vi etc/resolv.conf
nameserver 192.168.13.39
#search localdomain
添加区文件的权限
chmod 644 test.zx test.fx
-rw-r--r-- 1 root root 434 May 27 19:40 test.fx
-rw-r--r-- 1 root root 236 May 27 19:38 test.zx
7.使用nslookup测试
[root@localhost named]# nslookup
> ns1.benet.com
Server: 192.168.13.39
Address: 192.168.13.39#53
Name: ns1.benet.com
Address: 192.168.13.39
>
> 192.168.13.39
Server: 192.168.13.39
Address: 192.168.13.39#53
39.13.168.192.in-addr.arpa name = ns1.benet.com.
>
参照http://www.linuxdiyf.com/bbs/thread-187069-1-1.html