一.规划:

域: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

从服务器地址:172.16.100.4

(为了不影响实验效果,先关闭防火墙及SElinux

二.DNS服务器配置

同第上次配置主DNS服务器类似,只是配置文件稍有改动,配置好后启动服务即可:

/etc/named.conf:

options {

        directory "/var/named";

        allow-recursion { 172.16.100.0/24; };  (允许递归的网段,与此实验无关)

        notify yes; (启动通知功能)

};

 

zone "." IN {

        type hint;

        file "named.ca";

};

 

zone "localhost" IN {

        type master;

        file "named.localhost";

        allow-transfer { none; };

};

 

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

        type master;

        file "named.loopback";

        allow-transfer { none; };

};

 

zone "fsy.com" IN {

        type master;

        file "fsy.com.zone";

        allow-transfer { 172.16.100.4; };

};

 

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

        type master;

        file "172.16.100.zone";

        allow-transfer { 172.16.100.4; };

};

/var/named/fsy.com.zone:

$TTL 600

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

                                2016080102

                                1H

                                5M

                                2D

                                6H )

                IN      NS      ns1

                IN      NS      ns2

                IN      MX      10      mail

ns1             IN      A       172.16.100.3

ns2             IN      A       172.16.100.4

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

/var/named/172.16.100.zone:

$TTL 600

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

                                2016080101

                                1H

                                5M

                                2D

                                6H )

                IN      NS      ns1.fsy.com.

                IN      NS      ns2.fsy.com.

3               IN      PTR     ns1.fsy.com.

4               IN      PTR     ns2.fsy.com.

4               IN      PTR     mail.fsy.com.

5               IN      PTR     www.fsy.com.

3               IN      PTR     www.fsy.com.

三.DNS服务器配置:

1.[root@fsy-centos ~]# yum -y install bind

2.备份主配置文件,并将主配置文件改为以下内容

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

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

options {

        directory "/var/named";

        allow-recursion { 172.16.100.0/24; };

};

 

zone "." IN {

        type hint;

        file "named.ca";

};

 

zone "localhost" IN {

        type master;

        file "named.localhost";

        allow-transfer { none; };

};

 

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

        type master;

        file "named.loopback";

        allow-transfer { none; };

};

 

zone "fsy.com" IN {

        type slave;

        file "slaves/fsy.com.zone";

        masters { 172.16.100.3; };

        allow-transfer { none; };

};

 

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

        type slave;

        file "slaves/172.16.100.zone";

        masters { 172.16.100.3; };

        allow-transfer { none; };

};

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

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

4.改主配置文件的属组

[root@fsy-centos ~]# chgrp named /etc/named.conf

5.启动服务

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

6.将从服务器DNS指向172.16.100.4,测试即可

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

nameserver 172.16.100.4

测试无误,实验完成!