反向 DNS 查找不起作用 Centos 7 BIND

反向 DNS 查找不起作用 Centos 7 BIND

我正在设置一个 Ansible 实验室,我认为使用 DNS 是个好主意。我在 Centos 7 上使用命名 (BIND),并按照此指南设置 DNS:https://www.unixmen.com/setting-dns-server-centos-7/

我的正向查找工作正常。但是,我的反向查找却不顺利:

sam@gnome-desktop ~ $ host windows-7
windows-7.mylab.local has address 192.168.254.247
sam@gnome-desktop ~ $ host 192.168.254.247
Host 247.254.168.192.in-addr.arpa. not found: 3(NXDOMAIN) 

这是我的 /etc/named.conf 以及 /var 中的正向和反向文件。有人能指出我忽略的明显错误吗?谢谢!

[root@name-server ~]# cat /etc/named.conf 
//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
// See the BIND Administrator's Reference Manual (ARM) for details about the
// configuration located in /usr/share/doc/bind-{version}/Bv9ARM.html

options {
    listen-on port 53 { 192.168.254.249;}; ## Master DNS IP ##
    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";
    allow-query     { localhost; 192.168.254.0/24;}; ## IP Range##

    /* 
     - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
     - If you are building a RECURSIVE (caching) DNS server, you need to enable 
       recursion. 
     - If your recursive DNS server has a public IP address, you MUST enable access 
       control to limit queries to your legitimate users. Failing to do so will
       cause your server to become part of large scale DNS amplification 
       attacks. Implementing BCP38 within your network would greatly
       reduce such attack surface 
    */
    recursion yes;

    dnssec-enable yes;
    dnssec-validation yes;

    /* Path to ISC DLV key */
    bindkeys-file "/etc/named.iscdlv.key";

    managed-keys-directory "/var/named/dynamic";

    pid-file "/run/named/named.pid";
    session-keyfile "/run/named/session.key";
};

logging {
    channel default_debug {
            file "data/named.run";
            severity dynamic;
    };
};

zone "." IN {
    type hint;
    file "named.ca";
};

zone "mylab.local" IN {
type master;
file "forward.mylab";
allow-update { none; };
};

zone "254.168.192.in-addr.arpa" IN {
type master;
file "reverse.mylab";
allow-update { none; };
};

include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[root@name-server ~]# cat /var/named/forward.mylab 
$TTL 86400                                                                                           
@   IN  SOA     name-server.mylab.local. root.mylab.local. (                                             
    2011071001  ;Serial                                                                                   
    3600        ;Refresh                                                                                           
    1800        ;Retry                                                                                             
    604800      ;Expire                                                                                                    
    86400       ;Minimum TTL                                                                                               
)                                                                                                                                      
@       IN  NS         name-server.mylab.local.                                                                                        
@       IN  A           192.168.254.249                                                                                                       
@       IN  A           192.168.254.253                                                                                                              
@       IN  A           192.168.254.252                                                                                                                 
@       IN  A           192.168.254.251                                                                                                                       
@       IN  A           192.168.254.250                                                                                                                            
@       IN  A           192.168.254.248                                                                                                                              
@       IN  A           192.168.254.247                                                                                                                                    
name-server       IN  A   192.168.254.249                                                                                                                                      
gnome-desktop     IN  A   192.168.254.253
centos-ansible    IN  A   192.168.254.252
centos-7-node-1   IN  A   192.168.254.251
centos-7-node-2   IN  A   192.168.254.250
mint              IN  A   192.168.254.248
windows-7         IN  A   192.168.254.247

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[root@name-server ~]# cat /var/named/reverse.mylab 
$TTL 86400
@   IN  SOA     name-server.mylab.local. root.mylab.local. (
    2011071001  ;Serial
    3600        ;Refresh
    1800        ;Retry
    604800      ;Expire
    86400       ;Minimum TTL
)
@       IN  NS          name-server.mylab.local.
@       IN  PTR         mylab.local.
name-server           IN  A   192.168.254.249
gnome-desktop         IN  A   192.168.254.253
centos-ansible        IN  A   192.168.254.252
centos-7-node-1       IN  A   192.168.254.251
centos-7-node-2       IN  A   192.168.254.250
mint                  IN  A   192.168.254.248
windows-7             IN  A   192.168.254.247
101     IN  PTR         name-server.mylab.local
102     IN  PTR         gnome-desktop.mylab.local
103     IN  PTR         centos-ansible.mylab.local
104     IN  PTR         centos-7-node-1.mylab.local
105     IN  PTR         centos-7-node-2.mylab.local
106     IN  PTR         mint.mylab.local
107     IN  PTR         windows-7.mylab.local
[root@name-server ~]# 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

答案1

查看您的“反向”区域文件,需要澄清一件事:

反向区域中的所有A记录都完全无用,因为反向 DNS 不会执行任何神奇的反向查找。您的 nslookup 命令才不是尝试查找具有指定 IP 地址的所有域名。但实际上并没有发生这种情况。相反,反向 DNS 将 IP 地址转换为特殊域,然后仅有的PTR对其进行一个简单的查找。

因此,正如您在自己的 nslookup 输出中看到的那样,该地址192.168.254.247已转换为特殊域247.254.168.192.in-addr.arpa.。并且该域不在您的反向区域文件中!您有 101、102、103 的 PTR 记录……但没有 247。

记录看起来应该是这样的:

247     IN  PTR     windows-7.mylab.local.

配置的区域名称254.168.192.in-addr.arpa将被自动添加。但您也可以完整地写出它:

247.254.168.192.in-addr.arpa.     IN  PTR      windows-7.mylab.local.

(别忘了你的 PTR目标需要尾随.,否则它也会附加区域名称 - 您将获得类似这样的结果windows-7.mylab.local.254.168.192.in-addr.arpa.)

相关内容