Linux网络-DNS域名解析服务(反向解析)

反向解析

实验:一台装有Centos7的虚拟机,解析IP地址192.168.27.10,域名www.shaole.com

1.1安装bind

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

1.2配置主配置文件,将监听地址和可使用的DNS网段设为所有

[root@localhost ~]# vim /etc/named.conf
options {
     
        listen-on port 53 {
      any; };//将监听地址设为any
        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     {
      any; };//将DNS的网段设为any

1.3配置区域文件

[root@localhost ~]# vim /etc/named.rfc1912.zones

正向解析

zone "shaole,com" IN {
       //域名改为shaole.com
        type master;
        file "shaole.com.zone";
        allow-update {
      none; };
};

反向解析

zone "27.168.192.in-addr.arpa" IN {
     
        type master;
        file "shaole.com.zone";
        allow-update {
      none; };
};

Linux网络-DNS域名解析服务(反向解析)_第1张图片
Linux网络-DNS域名解析服务(反向解析)_第2张图片

[root@localhost ~]# cd /var/named
[root@localhost named]# ls
data  dynamic  named.ca  named.empty  named.localhost  named.loopback  slaves

在这里插入图片描述

1.4保持原属性复制模板文件

[root@localhost named]# cp -p named.localhost shaole.com.zone

1.5在区域数据文件/var/named/shaole.com.localhost中配置PTR 反向

[root@localhost named]# vim shaole.com.zone
$TTL 1D
@       IN SOA  @ admin.shaole.com. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      @
        A       192.168.27.10
www     A       192.168.27.10
10      PTR     www.shaole.com  //配置PTR反向指针,将地址指向域名(别忘了写最后的根域名)

Linux网络-DNS域名解析服务(反向解析)_第3张图片

1.6检查(不报错就是正确的)

[root@localhost named]# named-checkconf //检查主配置文件
[root@localhost named]# named-checkzone shaole.com /var/named/shaole.com.zone  //检查区域配置文件
zone shaole.com/IN: loaded serial 0
OK

1.7重启

[root@localhost named]# systemctl start named

1.8 查看端口

[root@localhost named]# netstat -anpu | grep 53

1.9在win10里面设置

Linux网络-DNS域名解析服务(反向解析)_第4张图片
解析
Linux网络-DNS域名解析服务(反向解析)_第5张图片
在Centos7上解析

[root@localhost named]# vim /etc/resolv.conf

[root@localhost named]# host 192.168.27.128
128.27.168.192.in-addr.arpa domain name pointer www.shaole.com.
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210524224426474.png)

你可能感兴趣的:(Linux网络-DNS域名解析服务(反向解析))