绑定配置无法查找主机名但使用IP成功

时间:2016-12-23 15:45:49

标签: dns

在这里发疯这是一个超级简单的绑定设置,它可以反向查找但不能解析名称的IP。

这些是我的(荒谬的)简单配置文件:

root@dns:/etc/bind/zones# cat db.192.168.1 
;
; BIND reverse data file for local loopback interface
;
$TTL    604800
@   IN  SOA dns.mycompany.com. admin.mycompany.com. (
              3     ; Serial
         604800     ; Refresh
          86400     ; Retry
        2419200     ; Expire
         604800 )   ; Negative Cache TTL
; name servers - NS records
      IN      NS      dns.mycompany.com.

; PTR Records
20   IN      PTR     dns.mycompany.com.         ; 192.168.1.20
149  IN      PTR     myharbor.mycompany.com.    ; 192.168.1.149




root@dns:/etc/bind/zones# cat db.mycompany.com 
$TTL    604800
@       IN      SOA     dns.mycompany.com. admin.mycompany.com. (
              3       ; Serial
         604800     ; Refresh
          86400     ; Retry
        2419200     ; Expire
         604800 )   ; Negative Cache TTL
;
; name servers - NS records
    IN      NS      dns.mycompany.com.

; A records
dns.mycompany.com.            IN      A       192.168.1.20
myharbor.mycompany.com.       IN      A       192.168.1.149

如果我查找IP,它可以正常工作:

root@dns:/etc/bind/zones# nslookup 192.168.1.149
Server:     192.168.1.20
Address:    192.168.1.20#53

149.1.168.192.in-addr.arpa  name = myharbor.mycompany.com.

但是,如果我查找名称......它会失败:

root@dns:/etc/bind/zones# nslookup myharbor.mycompany.com
;; Got SERVFAIL reply from 192.168.1.20, trying next server
Server:     192.168.1.20
Address:    192.168.1.20#53

** server can't find myharbor.mycompany.com: SERVFAIL

我确信这是一种愚蠢的行为。我可以在这里借一双眼睛吗?

感谢。

1 个答案:

答案 0 :(得分:-1)

我最终想通了。

罪魁祸首在/etc/bind/named.conf.local档案中。

zone "mycompany.com" {
     type master;
     file "/etc/bind/zones/db.mycompany.com"; # zone file path
};

zone "1.168.192.in-addr.arpa" {
      type master;
      file "/etc/bind/zones/db.192.168.1";  # 10.128.0.0/16 subnet
};

以下行中有一个拼写错误:

     file "/etc/bind/zones/db.mycompany.com"; # zone file path

最初读作:

     file "/etc/bind/zones/mycompany.com"; # zone file path

它无法找到文件导致路径被错误输入。

唷!

相关问题