带有 Bind9 的 DNS 服务器:无法解析正向和反向区域文件中的 DNS 记录

带有 Bind9 的 DNS 服务器:无法解析正向和反向区域文件中的 DNS 记录

大家好 :) 我尝试使用 bind9 设置自己的 DNS 服务器,但尽管我尝试了几个教程,但仍然收到相同的错误。启动 bind9 工作正常,但当我使用nslookupdig反对host1(存在于正向区域文件中)时,它永远无法解析 IP 地址。我在反向区域文件中遇到了同样的问题,使用 IP 地址作为参数而不是host1。如果我改为查找,例如,microsoft.com,我会得到答案。

例子:

nslookup host1.dirks.crtn
;; Got SERVFAIL reply from 192.168.56.2, trying next server
;; Got SERVFAIL reply from 192.168.56.2, trying next server
server 127.0.0.1
address 127.0.0.1#53

** server can't fint host1.dirks.crtn.dirks.crtn: SERVFAIL

我也尝试过host1

nslookup host1
;; Got SERVFAIL reply from 192.168.56.2, trying next server 
server: 192.168.56.2
address 192.168.56.2#53

** server can't find host1: NXDOMAIN

使用 microsoft.com:

nslookup microsoft.com
server: 192.168.56.2
address: 192.168.56.2#53

Non-authoritative answer:
name: microsoft.com
address: 134.170.188.221
name: microsoft.com
address 134.170.185.46

我的当前文件:

文件 /etc/bind/named.conf.options:

options {
directory "/var/cache/bind";
recursion yes;

  forwarders {
  8.8.8.8;
  8.8.4.4;
  };
  allow-query {
  192.168.56.0/24;
  };
  allow-transfer {
  192.168.56.0/24;
  };
};

文件 /etc/bind/named.conf.local:

zone "dirks.crtn" {
type master;
file "etc/bind/zones/dirks.crtn.db";
};

zone "56.168.192.in-addr.arpa" {
type master;
file "etc/bind/zones/rev.56.168.192.in-addr.arpa";
};

前向区域文件 - /etc/bind/zones/dirks.crtn.db:

$ORIGIN .
$TTL 907200          ; 1 week 3 days 12 hours

dirks.crtn           IN SOA filtjener.dirks.crtn. webmaster.dirks.crtn. (
       1263527838    ; serial
       10800         ; refresh
       3600          ; retry (1 hour)
       604800        ; expire (1 week)
       38400         ; minimum (10 hours 40 minutes)
)
; name server - NS records
        NS   filtjener.dirks.crtn.
; name server - A records
filtjener.dirks.crtn.      A    192.168.56.2

$ORIGIN dirks.crtn.
host1   A   192.168.56.21
host2   A   192.168.56.22
host3   A   192.168.56.23

反向区域文件 - /etc/bind/zones/rev.56.168.192.in-addr.arpa:

$TTL 907200     ; 1 week 3 days 12 hours

@ IN SOA filtjener.dirks.crtn. webmaster.dirks.crtn. (
     1263187356    ; serial
     10800         ; refresh (3 hours)
     3600          ; retry (1 hour)
     60400         ; expire (1 week)
     38400         ; minimum (10 hours 40 minutes)
)

         NS filtjener.dirks.crtn.
; PTR records
21      PTR      host1.dirks.crtn.
22      PTR      host2.dirks.crtn.
23      PTR      host3.dirks.crtn.

文件 /etc/resolvconf/resolv.conf.d/head:

search dirks.crtn
nameserver 192.168.56.2

文件 /etc/network/interfaces:

auto lo
iface eth1 inet static
address 192.168.56.2
netmask 255.255.255.0

我检查了文件:

sudo named-checkconf

sudo named-chekckzone rev.56.168.192.in-addr.arpa /etc/bind/zones/rev.56.168.192.in-addr.arpa
zone rev.56.168.192.in-addr.arpa/IN: loaded serial 1263187356
OK

sudo named-checkzone dirks.crtn /etc/bind/zones/dirks.crtn.db
zone dirks.crtn/IN: loaded serial 1263527838
OK

并重新启动bind9:

sudo /etc/init.d/bind9 restart
* Stopping domain name service... bind9 [ok]
waiting for pid 2765 to die

* starting domain name service... bind9 [ok]

我正在使用 VirtualBox,由于我无法从 VirtualBox 复制和粘贴,所以文件中可能会出现小错误。

有人知道我在这里可能做错了什么吗?:)我很感激任何帮助:)

答案1

所以转发工作正常。配置文件中的内容对我来说确实有点奇怪。请注意,我从来没有能够让事情与 一起工作$ORIGIN。我确信它在某种程度上确实有效,只是对我来说不行。

尝试dirks.crtn.db

$TTL 38400
@      IN SOA filtjener.dirks.crtn. webmaster.dirks.crtn. (
       1263527838    ; serial
       10800         ; refresh
       3600          ; retry
       604800        ; expire
       38400 )       ; Negative Cache TTL
       IN  A  192.168.56.2
;
; name server - NS records
@      IN  NS   filtjener.dirks.crtn.
; name server - A records
filtjener IN   A    192.168.56.2

host1   IN A   192.168.56.21
host2   IN A   192.168.56.22
host3   IN A   192.168.56.23

尝试rev.56.168.192.in-addr.arpa

$TTL 38400

@ IN SOA filtjener.dirks.crtn. webmaster.dirks.crtn. (
     1263187356    ; serial
     38400         ; refresh
     3600          ; retry 1 hour
     60400         ; expire 1 week
     38400 )       ; negative cache TTL
;
@    IN   NS    filtjener.dirks.crtn.
2    IN   PTR   filtjener.dirks.crtn.
21   IN   PTR   host1.dirks.crtn.
22   IN   PTR   host2.dirks.crtn.
23   IN   PTR   host3.dirks.crtn.

您不需要使用sudowith named-checkzone,并注意,反向区域检查的命令是:

named-checkzone 56.168.192.in-addr.arpa rev.56.168.192.in-addr.arpa

参考

答案2

所以我最终在 /etc/bind/named.conf.local 中找到了我自己的问题的答案,我忘了在“etc”前面添加“/”。

我的方式:

zone "dirks.crtn" {
type master;
file "etc/bind/zones/dirks.crtn.db";
};

正确方法:

zone "dirks.crtn" {
type master;
file "/etc/bind/zones/dirks.crtn.db";
};

我觉得自己有点傻,但至少我能够解析地址和主机名。

相关内容