简单DNS服务器配置

1:安装DNS相关的包

bind-chroot-9.3.4-10.P1.el5

bind-libs-9.3.4-10.P1.el5

ypbind-1.19-11.el5

bind-utils-9.3.4-10.P1.el5

bind-9.3.4-10.P1.el5

rpm –ivh

例如:rpm –ivh  ind-chroot-9.3.4-10.P1.el5其他的也像这样安装。

2:还需要安装一个DNS的参考包,方便安装DNS

caching-nameserver-9.3.4-10.P1.el5.i386.rpm

rpm –ivh caching-nameserver-9.3.4-10.P1.el5.i386.rpm

3:配置DNS的主配置文件

cd /var/named/chroot/etc

然后cp –p named.caching-nameserver.conf  named.conf

4:编辑named.conf

Vim named.conf

15273637行的localhost改成 any即可

保存退出wq

5vim named.rfc1912.zones

复制里面的15-19行,然后粘贴改动

zone "localdomain" IN {

          type master;

          file "localdomain.zone";

          allow-update { none; };

 };

改成

zone "abc.com" IN {

          type master;

          file "abc.com.db";

          allow-update { none; };

 };

6cd /var/named/chroot/var/named

Cp –p localhost.zone abc.com.db

接着编辑

Vim abc.com.db

里面的内容改为:

$TTL    86400

@               IN SOA  ns.abc.com.       root.sina.com. (

                                        42              ; serial (d. adams)

                                        3H              ; refresh

                                        15M             ; retry

                                        1W              ; expiry

                                        1D )            ; minimum

 

                IN NS           ns.abc.com.

ns              IN A            192.168.100.60

www             IN A            1.1.1.1

ftp             IN A            2.2.2.2

mail            IN A            3.3.3.3

@               IN MX 10        mail

pop3            IN CNAME        mail

smtp            IN CNAME        mail

 

6:编辑好之后保存退出,然后启动DNS服务器

Service named restart;

7:测试DNS服务器是否配置成功

测试1Nslookup

正确结果

Server:           127.0.0.1

Address:  127.0.0.1#53

 

Name:     www.abc.com

Address: 1.1.1.1

 

测试2Nslookup mail.abc.com

Server:           127.0.0.1

Address:  127.0.0.1#53

 

Name:     mail.abc.com

Address: 3.3.3.3

测试3Nslookup

Server:           127.0.0.1

Address:  127.0.0.1#53

 

Name:     ftp.abc.com

Address: 2.2.2.2

测试4Nslookup ns.abc.com

Server:           127.0.0.1

Address:  127.0.0.1#53

 

Name:     ns.abc.com

Address: 192.168.100.60

 

 

 

配置辅助DNS服务器

说明:继续以上面的实验为基础

1:以上面的那台做主DNS服务器

2:现在另开一台主机配置辅助DNS服务器

3:首先为这台新开的机器安装DNS需要的包,配置DNS服务器,上面已经说明过,如果不会参考上面的

4:安装好之后启动DNS服务器

Service named start

5:配置DNS辅助服务器的主配置文件

cd /var/named/chroot/etc

然后cp –p named.caching-nameserver.conf  named.conf

Vim named.conf

15273637行的localhost改成 any即可

保存退出wq

6: vim named.rfc1912.zones

复制里面的15-19行,然后粘贴改动

zone "localdomain" IN {

          type master;

          file "localdomain.zone";

          allow-update { none; };

 };

改成

zone "abc.com" IN {

          type slave;

          master {

   192.168.100.60;   };

注意这个地址前面至少有一个空格,地址后面的分号和后面的也少有一个空格

          file "slaves/abc.com.db";

 };

7:然后执行rndc reload 进行数据的重新加载