Ubuntu、BIND9 和名称解析

Ubuntu、BIND9 和名称解析

我已在 Ubuntu 22.04 LTS 服务器上安装了 BIND9 作为 home.twelsh.co.uk 域的主名称服务器。它是通过 apt 安装的,配置文件是在数字海洋操作方法

当我在客户端 PC 上执行挖掘请求时,对于名称服务器,我得到了正确的答案

twelsh@builder-box:~$ dig @192.168.0.86 NS home.twelsh.co.uk

; <<>> DiG 9.18.18-0ubuntu0.22.04.2-Ubuntu <<>> @192.168.0.86 NS home.twelsh.co.uk
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20315
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 3

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
; COOKIE: 5e4f9d4078dbda280100000065d90bd4e2ffc3f2dc27663a (good)
;; QUESTION SECTION:
;home.twelsh.co.uk.             IN      NS

;; ANSWER SECTION:
home.twelsh.co.uk.      300     IN      NS      ns1.home.twelsh.co.uk.
home.twelsh.co.uk.      300     IN      NS      ns2.home.twelsh.co.uk.

;; ADDITIONAL SECTION:
ns1.home.twelsh.co.uk.  300     IN      A       192.168.0.86
ns2.home.twelsh.co.uk.  300     IN      A       192.168.0.88

;; Query time: 0 msec
;; SERVER: 192.168.0.86#53(192.168.0.86) (UDP)
;; WHEN: Fri Feb 23 21:19:16 UTC 2024
;; MSG SIZE  rcvd: 142

如果我对主机 calvin 执行相同的操作,我会得到以下信息,显示名称但没有关联的 IP 地址。谁能告诉我我哪里出了问题。我正在拔头发。

我已阅读并重读本文但仍然有问题。 -

twelsh@builder-box:~$ dig @192.168.0.86 A calvin

; <<>> DiG 9.18.18-0ubuntu0.22.04.2-Ubuntu <<>> @192.168.0.86 A calvin
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 7947
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
; COOKIE: 751c6a8a04abd91b0100000065d90ad04417a14eccdffc7f (good)
;; QUESTION SECTION:
;calvin.                                IN      A

;; AUTHORITY SECTION:
.                       10800   IN      SOA     a.root-servers.net. nstld.verisign- 
grs.com. 2024022301 1800 900 604800 86400

;; Query time: 32 msec
;; SERVER: 192.168.0.86#53(192.168.0.86) (UDP)
;; WHEN: Fri Feb 23 21:14:56 UTC 2024
;; MSG SIZE  rcvd: 138

据我所知,我的区域文件很好

twelsh@ns1:~$ sudo named-checkzone home.twelsh.co.uk 
/etc/bind/zones/db.home.twelsh.co.uk
zone home.twelsh.co.uk/IN: loaded serial 11
OK

和我的反向查找

twelsh@ns1:~$ sudo named-checkzone 0.168.192.in-addr.arpa /etc/bind/zones/db.192.168.0
zone 0.168.192.in-addr.arpa/IN: loaded serial 10
OK

这是我的区域和反向查找文件 /etc/bind/zones/db.home.twelsh.co.uk

;; Optimized BIND9 Forward Zone File
$ORIGIN home.twelsh.co.uk.
$TTL    5m

@       IN SOA  ns1.home.twelsh.co.uk root.home.twelsh.co.uk. (
                  11          ; Serial   
                  7d        ; Refresh
                  1d        ; Retry
                  28d       ; Expire
                  7d )        ; Minimum TTL

       IN NS  ns1.home.twelsh.co.uk.
       IN NS  ns2.home.twelsh.co.uk.

n8n               IN A 192.168.0.79
builder-box       IN A 192.168.0.82
dev-server        IN A 192.168.0.83
staging-server    IN A 192.168.0.84
ns1               IN A 192.168.0.86
ns2               IN A 192.168.0.88
calvin            IN A 192.168.0.89

反向区域文件

$ORIGIN 0.168.192.in-addr.arpa.
$TTL    5m
@       IN      SOA  home.twelsh.co.uk. root.home.twelsh.co.uk. (
                     10          ; serial number incrementation example here
                     7d         ; refresh interval
                     1d         ; retry interval
                     28d        ; expiry time
                     7d )       ; minimum cache lifetime

        IN  NS  ns1.home.
        IN  NS  ns2.home.

86      IN  PTR  ns1.home.
88      IN  PTR  ns2.home.

79      IN  PTR  n8n.home.
82      IN  PTR  builder-box.home.
83      IN  PTR  dev-server.home.
84      IN  PTR  staging-server.home.
86      IN  PTR  ns1.home.
88      IN  PTR  ns2.home.
89      IN  PTR  calvin.home.

/etc/named.conf.local

//
// Do any local configuration here
//

// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";

zone "home.twelsh.co.uk" {
    type master;
    file "/etc/bind/zones/db.home.twelsh.co.uk"; # zone file path
    allow-transfer {192.168.0.88; };             # ns2 private IP address - secondary
};


zone "0.168.192.in-addr.arpa" {
    type master;
    file "/etc/bind/zones/db.192.168.0.0";  # 192.168.0.0/24 subnet
    allow-transfer { 192.168.0.88; };       # ns2 private IP address - secondary
};

相关内容