规划:

域:fsy.com地址段:172.16.100.0/24

ns地址:172.16.100.3

www地址:172.16.100.3, 172.16.100.5

mail地址:172.16.100.4

ftp 别名: www

一.配置缓存DNS服务器:

    1.安装软件包

        [root@fsy-Centos6 ~]# yum -y install bind 

    2.备份主配置文件

        [root@fsy-Centos6 ~]# mv /etc/named.conf /etc/named.conf.orig 

    3.编辑主配置文件,并添加以下内容

        [root@fsy-Centos6 ~]# vim /etc/named.conf

        options {

                directory "/var/named";

        };

         

        zone "." IN {

                type hint;

                file "named.ca";

        };

         

        zone "localhost" IN {

                type master;

                file "named.localhost";

        };

         

        zone "0.0.127.in-addr.arpa" IN {

                type master;

                file "named.loopback";

        };

    4.根据安装bind时生成的主配置文件改当前自定义的配置文件的属主、属组及权限

    [root@fsy-Centos6 ~]# chown root:named /etc/named.conf

    [root@fsy-Centos6 ~]# chmod 640 /etc/named.conf

    5.启动服务

    [root@fsy-Centos6 ~]# service named start

    6.保证此主机可以访问到互联网的情况下,将主机的DNS服务器指向本机地址(我的地址是172.16.100.3

    [root@fsy-Centos6 ~]# vim /etc/resolv.conf

    nameserver 172.16.100.3

    7.[root@fsy-Centos6 ~]# ping www.baidu.com

    此时可以ping通,说明一个简单的缓存DNS服务器已搭建完成

    8.将此服务设置为开机自动启动

    [root@fsy-Centos6 ~]# chkconfig --list named

    [root@fsy-Centos6 ~]# chkconfig  named on

二.配置主DNS服务器

做好以上的配置后:

1.修改主配置文件,并添加以下内容

[root@fsy-Centos6 ~]# vim /etc/named.conf

zone "fsy.com" IN {

        type master;

        file "fsy.com.zone";

};

 

zone "100.16.172.in-addr.arpa" IN {

        type master;

        file "172.16.100.zone";

};

2.检查主配置文件是否有语法错误

[root@fsy-Centos6 ~]# named-checkconf

3.编辑正向区域数据文件

[root@fsy-Centos6 ~]# cd /var/named/

[root@fsy-Centos6 named]# vim fsy.com.zone

添加以下内容:

$TTL 600

@        IN      SOA     ns1.fsy.com.    admin.fsy.com.  (

                                2016080101

                                1H

                                5M

                                2D

                                6H )

                IN      NS      ns1

                IN      MX      10      mail

ns1             IN      A       172.16.100.3

mail            IN      A       172.16.100.4

www            IN      A       172.16.100.5

www            IN      A       172.16.100.3

ftp              IN      CNAME   www

4.根据安装bind时生成的区域数据文件改当前自定义的配置文件的属主、属组及权限

[root@fsy-Centos6 named]# chmod 640 fsy.com.zone

[root@fsy-Centos6 named]# chown root:named fsy.com.zone

5.测试正向区域数据文件看有无语法错误

[root@fsy-Centos6 named]# named-checkzone "fsy.com" /var/named/fsy.com.zone

6.编辑反向区域数据文件

[root@fsy-Centos6 named]# cp fsy.com.zone 172.16.100.zone -p

[root@fsy-Centos6 named]# vim 172.16.100.zone

修改为以下内容:

$TTL 600

@       IN      SOA     ns1.fsy.com.    admin.fsy.com.  (

                                2016080101

                                1H

                                5M

                                2D

                                6H )

                IN      NS      ns1.fsy.com.

3               IN      PTR     ns1.fsy.com.

4               IN      PTR     mail.fsy.com.

5               IN      PTR     www.fsy.com.

3               IN      PTR    www.fsy.com.

 

7.测试反向区域数据文件看有无语法错误

    [root@fsy-Centos6 named]# named-checkzone "100.16.172.in-addr.arpa" 172.16.100.zone

8.重启服务

[root@fsy-Centos6 named]# service named restart

9.测试

[root@fsy-Centos6 named]# dig -x 172.16.100.3

[root@fsy-Centos6 named]# dig -t A www.fsy.com

正向和反向解析都正常,服务搭建成功