可以在一台綁定伺服器上託管父網域和子網域嗎?

可以在一台綁定伺服器上託管父網域和子網域嗎?

註:這是一個轉發我之前的問題,被擱置,並要求重新措辭以使其更加清晰(希望這更有意義)


我安裝了一個 DNS 伺服器bind,我嘗試將其設定為託管一個父網域 ( example.org) 和兩個子網域 (cnc.example.orgreport.example.org),以便任何網域中的裝置都可以透過單一 DNS 伺服器提供 DNS 查詢服務。

我的第一個問題這可能嗎?

如果是這樣,為什麼我會收到以下錯誤?

當我nslookup host1report.example.org我收到的網域中執行此操作時

server can't find host1: SERVFAIL

當我nslookup host2cnc.example.org我收到的網域中執行此操作時

server can't find host1: SERVFAIL

網路拓撲結構

設定如下:

主機1:

  • IP 192.168.252.21/24
  • 網域解析 192.168.252.22
  • /etc/hosts包含host1.cnc.example.org

主機2:

  • IP 192.168.252.20/24
  • 網域解析 192.168.252.22
  • /etc/hosts包含host2.report.example.org

DNS伺服器:

  • IP 192.168.252.22/24
  • 網域解析 127.0.0.1
  • /etc/hosts包含DNSServer.example.org

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 "example.org" {
    type master;
    file "/etc/bind/zones/example.org";
#    allow-transfer { 192.168.252.22; };
};

zone "cnc.example.org" {
    type master;
    file "/etc/bind/zones/cnc.example.org";
#    allow-transfer { 192.168.252.22; };
};

zone "report.example.org" {
    type master;
    file "/etc/bind/zones/report.example.org";
#    allow-transfer { 192.168.252.22; };
};

zone "252.168.192.in-appr.arpa" {
     type master;
     file "/etc/bind/zones/reverse/rev.252.168.192";
     allow-transfer { 192.168.252.22; };
};

example.org配置

;
; BIND data for example.org or report.example.org
;
$TTL 3h
@           IN  SOA DNSServer.example.org.  root.example.org. (
                        1       ; serial
                        3h      ; refresh
                        1h      ; retry
                        1w      ; expire
                        1h )    ; minimum
;
; main domain name servers - NS records
                    IN  NS  DNSServer.example.org.


; main domain name servers - A records
DNSServer               IN  A   192.168.252.22


;delegated zones
cnc.example.org.                IN  NS  DNSServer.example.org.
report.example.org.         IN  NS  DNSServer.example.org.

* DNSServer 上 /etc/resolv.conf 的輸出 *

  # Generated by NetworkManager
    search example.org
    nameserver 127.0.0.1

* host1 上 /etc/resolv.conf 的輸出 *

 # Generated by NetworkManager
    search report.example.org
    nameserver 192.168.252.22

* 主機 2 上 /etc/resolv.conf 的輸出 *

  # Generated by NetworkManager
    search cnc.example.org
    nameserver 192.168.252.22

* DNSServer 上的 dig DNSServer 的輸出 *

root@DNSServer:/etc/bind/zones/reverse# dig DNSServer

; <<>> DiG 9.10.3-P4-Debian <<>> DNSServer
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 45573
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;DNSServer.         IN  A

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Nov 27 10:47:23 GMT 2017
;; MSG SIZE  rcvd: 38

* 使用 dig DNSServer.example.org 輸出 *

   root@DNSServer:/home/osboxes# dig DNSServer.example.org

    ; <<>> DiG 9.10.3-P4-Debian <<>> DNSServer.example.org
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12335
    ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

    ;; OPT PSEUDOSECTION:
    ; EDNS: version: 0, flags:; udp: 4096
    ;; QUESTION SECTION:
    ;DNSServer.example.org.     IN  A

    ;; ANSWER SECTION:
    DNSServer.example.org.  10800   IN  A   192.168.252.22

    ;; AUTHORITY SECTION:
    example.org.        10800   IN  NS  DNSServer.example.org.

    ;; Query time: 0 msec
    ;; SERVER: 127.0.0.1#53(127.0.0.1)
    ;; WHEN: Mon Nov 27 11:01:19 GMT 2017
    ;; MSG SIZE  rcvd: 79

* DNSServer 上的 dig host1 的輸出 *

root@DNSServer:/etc/bind/zones/reverse# dig host1

; <<>> DiG 9.10.3-P4-Debian <<>> host1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 19414
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;host1.         IN  A

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Nov 27 10:48:15 GMT 2017
;; MSG SIZE  rcvd: 40

cnc.example.org配置

;
; BIND data for example.org or report.example.org
;
$TTL 3h
@           IN  SOA DNSServer.example.org.  root.example.org. (
                        1       ; serial
                        3h      ; refresh
                        1h      ; retry
                        1w      ; expire
                        1h )    ; minimum
;
; main domain name servers - NS records
@                   IN  NS  DNSServer.example.org.


; main domain name servers - A records
;DNSServer              IN  A   192.168.252.22


;192.168.252.0/24 - A Records
host1.cnc.example.org.      IN  A   192.168.252.21

report.example.org配置

;
; BIND data for example.org or report.example.org
;
$TTL 3h
@           IN  SOA DNSServer.example.org.  root.example.org. (
                        1       ; serial
                        3h      ; refresh
                        1h      ; retry
                        1w      ; expire
                        1h )    ; minimum
;
; main domain name servers - NS records
@                   IN  NS  DNSServer.example.org.

; main domain name servers - A records
DNSServer               IN  A   192.168.252.22

;192.168.252.0/24 - A Records
host2.report.example.org.   IN  A   192.168.252.20

謝謝

答案1

您可以使用委派,但除非您確實需要它,否則我建議您保持簡單並使用包含example.orgcnc.example.org和 的一個區域report.example.org

;
; BIND data for example.org
;
$TTL 3h
@           IN  SOA DNSServer.example.org.  root.example.org. (
                        1       ; serial
                        3h      ; refresh
                        1h      ; retry
                        1w      ; expire
                        1h )    ; minimum
;
; main domain name servers - NS records
                    IN  NS  DNSServer.example.org.

; main domain name servers - A records
DNSServer           IN  A  192.168.252.22

; public targets
cnc                 IN  CNAME  host1.cnc
report              IN  CNAME  host2.report

; hosts delivering services
host1.cnc           IN  A   192.168.252.21
host2.report        IN  A   192.168.252.20

引用評論中的內容:

當我在 DNS 伺服器上時,nslookup host1我得到

root@host1:/home/osbixes# nslookup host2
Server: 127.0.0.1
Address 127.0.0.1#53
** server can’t find host2: SERVFAIL

DNSServer 上沒有搜尋路徑,但網域是example.org,這表示所有不合格的名稱都必須在該網域中。沒有正確host2.example.orgnslookup未能返回您的答案。在這種情況下,您要么需要將domain example.org您的替換/etc/resolv.confsearch example.org report.example.org,要么查找nslookup host2.report

從主機1或主機2我得到

root@host1:/home/osbixes# nslookup host2
Server: 192.168.252.22
Address 192.168.252.22#53
** server can’t find host2: SERVFAIL

同樣的原因。您的網域(搜尋路徑)/etc/resolv.conf不包含包含的元件,host2因此在任何地方nslookup都看不到不合格的名稱host2

我假設host1 和 host2 上的/etc/hosts/etc/hostname檔案應該仍然是host1.cnc.example.orghost2.report.example.org

/etc/hosts當你說「應該」時,我真的不知道你的意思是什麼host1.cnc.example.org。該/etc/hosts檔案是主機名稱和 IP 位址之間映射的另一種方式。如果您只有兩到三個主機名,您不妨避免內部 DNS 的複雜性,只需將這些條目放入/etc/hosts.另一方面,如果您擁有合理數量的主機,那麼 DNS 對於本地網路來說是一個很好的集中式解決方案。 (但請記住,這是nslookup故意忽略的/etc/hosts。)

當我這樣做時,從任一主機nslookup host1.cnc.example.org,或者nslookup host2.report.example.org它正確解析了 IP 位址

是的。您提供了一個完全限定的名稱,該名稱nslookup(和bind) 可以正確解析。這證明任一 DNS 都運作良好。

我需要一個 DNS 伺服器來處理 和 的任何查詢example.orgcnc.example.org以便report.example.org當新設備與網路通訊以請求執行新命令時,它會查詢cnc.example.org並定向到host1.cnc.example.org(192.168.252.21),但當它想要發送報告時返回網絡,它查詢report.example.org域並定向到host2.report.example.org(192.168.252.20)

為此,您將CNAME在 DNS 中使用(別名)記錄,以便將 的查詢report.example.org對應到主機host2.report.example.org。請注意,您的問題中沒有任何技術原因,為什麼host2不應該呼叫host2.example.orgCNAME記錄可以指向任何地方,而不僅僅是當前(子)域中的主機。

答案2

是的。但無需為子網域建立單獨的配置。

末尾的“A”.表示完整域名,沒有“A”.則表示原始域的子域。

cnc.example.com僅在配置中新增這樣的條目example.com

host1.cnc      IN  A   192.168.252.21    

因此,您需要以下更新

  1. 刪除cnc.example.orgreport.example.comnamed.conf.local
  2. .在父域的配置中新增與子網域對應的所有條目(不含結尾)。您也可以在父母的區域中明確提及他們,例如

    host1.cnc.example.com.  IN A  192.168.252.21
    
  3. cnc.example.com刪除和對應的區域檔案report.example.com並重新啟動BIND伺服器。

相關內容