CentOS7-RHCE服务----DNS

实验要求:
1、建立DNS服务器,负责解析的域为openedu.com

2、要求将MX记录指向mail.openedu.com,且对应A记录为本机IP

3、要求将NS记录指向ns1.openedu.com,且对应A记录为本机IP

4、建立www的A记录指向本机IP; 建立ftp对应A记录为x.x.x.123; 为mail主机建立别名记录pop3和smtp

5、为所有A记录建立PTR记录

6、openedu.com区域仅允许本网段中的主机x.x.x.200(NS为ns2.openedu.com)做区域传送; 对应的反向区域不允许任何主机做区域传送

7、客户端测试

1、安装bind软件

[root@node01 ~]# yum install bind  -y

2、修改主配置文件

[root@node01 ~]# vim /etc/named.conf
# 注释一行,改俩行
listen-on port 53 { 192.168.11.110; };
        //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";
        recursing-file  "/var/named/data/named.recursing";
        secroots-file   "/var/named/data/named.secroots";
        allow-query     { 192.168.11.0/24; }; # 修改为本网段,或者用any

3、修改区域文件

[root@node01 ~]# vim /etc/named.rfc1912.zones
zone "openedu.com" IN {
        type master;
        file "openedu.com.zone";
};

zone "11.168.192.in-addr.arpa" IN {
        type master;
        file "192.168.11.zone";
};

4、拷贝模板解析文件

[root@node01 named]# cat openedu.com.zone
$TTL 1D
@       IN SOA  dns1.openedu.com. admin.openedu.com. (
                                        2023032001      ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      dns1.openedu.com.
        MX 5    mail.openedu.com.
dns1    A       192.168.11.110
mail    A       192.168.11.110
www     A       192.168.11.110
ftp     A       192.168.11.123
pop3    CNAME   mail
smtp    CNAME   mail

5、语法检测

[root@node01 named]# named-checkzone openedu.com /var/named/openedu.com.zone
zone openedu.com/IN: loaded serial 2023032001
OK

6、重启服务

[root@node01 named]# systemctl restart named

7、客户端测试

# 安装工具
[root@node02 ~]# yum install bind-utils.x86_64 -y
[root@node02 ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.11.110
# 测试命令
> www.openedu.com
Server:         192.168.11.110
Address:        192.168.11.110#53

Name:   www.openedu.com
Address: 192.168.11.110
> mail.openedu.com
Server:         192.168.11.110
Address:        192.168.11.110#53

Name:   mail.openedu.com
Address: 192.168.11.110
> pop3.openedu,com
^C
[root@node02 ~]# nslookup
> pop3.openedu.com
Server:         192.168.11.110
Address:        192.168.11.110#53

pop3.openedu.com        canonical name = mail.openedu.com.
Name:   mail.openedu.com
Address: 192.168.11.110
[root@node02 ~]# nslookup
> ftp.openedu.com
Server:         192.168.11.110
Address:        192.168.11.110#53

Name:   ftp.openedu.com
Address: 192.168.11.123
> pop3.openedu.com
Server:         192.168.11.110
Address:        192.168.11.110#53

pop3.openedu.com        canonical name = mail.openedu.com.
Name:   mail.openedu.com
Address: 192.168.11.110

8、修改反向解析域

[root@node01 named]# cat 192.168.11.zone
$TTL 1D
@       IN SOA dns1.openedu.com. admin.openedu.com. (
                                        2023032001      ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      dns1.openedu.com.
dns1.openedu.com.       A       192.168.11.110
110     PTR     dns1.openedu.com.
110     PTR     mail.openedu.com.
110     PTR     www.openedu.com.
123     PTR     ftp.openedu.com.

9、语法检测

[root@node01 named]# named-checkzone openedu.com 192.168.11.zone
zone openedu.com/IN: loaded serial 2023032001
OK

10、重启服务

[root@node01 named]# systemctl restart named

11、客户端测试

[root@node02 ~]# host -t PTR 192.168.11.110
110.11.168.192.in-addr.arpa domain name pointer www.openedu.com.
110.11.168.192.in-addr.arpa domain name pointer dns1.openedu.com.
110.11.168.192.in-addr.arpa domain name pointer ftp.openedu.com.
110.11.168.192.in-addr.arpa domain name pointer mail.openedu.com.
[root@node02 ~]# host -t PTR 192.168.11.123
123.11.168.192.in-addr.arpa domain name pointer ftp.openedu.com.

12、添加允许传送的从服务器,allow-transfer { address_match_elment;...};

[root@node01 named]# vim /etc/named.conf
options {
        listen-on port 53 { 192.168.11.110; };
        //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";
        recursing-file  "/var/named/data/named.recursing";
        secroots-file   "/var/named/data/named.secroots";
        allow-query     { 192.168.11.0/24; };
        allow-transfer { 192.168.11.200;};

13、添加NS2

[root@node01 named]# vim openedu.com.zone
$TTL 1D
@       IN SOA  dns1.openedu.com. admin.openedu.com. (
                                        2023032002      ; serial #注意手动修改序列号
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      dns1.openedu.com.
        NS      dns2.openedu.com.
        MX 5    mail.openedu.com.
dns1    A       192.168.11.110
dns2    A       192.168.11.200
mail    A       192.168.11.110
www     A       192.168.11.110
ftp     A       192.168.11.123
pop3    CNAME   mail
smtp    CNAME   mail

14、语法检测+重启服务

[root@node01 named]# named-checkzone openedu.com openedu.com.zone
zone openedu.com/IN: loaded serial 2023032002
OK
[root@node01 named]# systemctl restart named

15、客户端测试

反向解析:
[root@node02 ~]# host -t PTR 192.168.11.123
123.11.168.192.in-addr.arpa domain name pointer ftp.openedu.com.
[root@node02 ~]# host -t PTR 192.168.11.110
110.11.168.192.in-addr.arpa domain name pointer mail.openedu.com.
110.11.168.192.in-addr.arpa domain name pointer www.openedu.com.
110.11.168.192.in-addr.arpa domain name pointer dns1.openedu.com.

正向解析
[root@node02 ~]# nslookup
> www.openedu.com.
Server:         192.168.11.110
Address:        192.168.11.110#53

Name:   www.openedu.com
Address: 192.168.11.110
> mail.openedu.com
Server:         192.168.11.110
Address:        192.168.11.110#53

Name:   mail.openedu.com
Address: 192.168.11.110
> dns2.openedu.com
Server:         192.168.11.110
Address:        192.168.11.110#53

Name:   dns2.openedu.com
Address: 192.168.11.200

实验完成,恢复环境

出处:http://www.cnblogs.com/sre-chan/

-------------------------------------------

个性签名:今天做了别人不想做的事,明天你就做得到别人做不到的事,尝试你都不敢,你拿什么赢!

如果觉得这篇文章对你有小小的帮助的话,记得在右下角点个“推荐”哦,博主在此感谢!