Domain-Name-System

如何綁定以返回與 DNSMASQ 返回相同的 dns 答案?

  • September 12, 2014

由於 Dnsmasq 不支持 Views,我已經安裝並配置了 bind9。一切正常,但是我注意到我的綁定伺服器沒有返回與 Dnsmasq 相同的答案/響應的特定條目。我怎樣才能做到這一點?

這是我的 Dnsmasq 伺服器的配置:

address=/override-url.example.com/54.210.175.6

這是來自我的 Dnsmaq 伺服器的 dns 響應:

$ dig @127.0.0.1 override-url.example.com

回复:

; <<>> DiG 9.9.5-3-Ubuntu <<>> @127.0.0.1 override-url.example.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53532
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;override-url.example.com.  IN  A

;; ANSWER SECTION:
override-url.example.com. 0 IN  A   1.2.3.4

;; Query time: 1 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Aug 06 21:58:44 UTC 2014
;; MSG SIZE  rcvd: 58

這是我的綁定配置和區域文件:

   zone "override-url.example.com" {
           type master;
           file "/etc/bind/override-url.example.com";
   };

和區域文件:

$TTL    3600
$ORIGIN override-url.example.com.

@       IN SOA localhost. hostmaster.localhost.com. (
       20140805 ; sn = serial number
       86400    ; ref = refresh = 1d
       900      ; ret = update retry = 15m
       1209600  ; ex = expiry = 2w
       3600     ; min = minimum = 1h
       )

       ; we need at least 1 name server
       IN NS

       ; override public ip with this address
       IN A 54.210.127.53

當然,這裡是從 bind 中返回的與上面的答案不匹配的數據。我想盡可能地匹配它。

; <<>> DiG 9.8.3-P1 <<>> override-url.example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 12930
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;override-url.example.com.  IN  A

;; Query time: 36 msec
;; SERVER: 54.88.72.140#53(54.88.72.140)
;; WHEN: Wed Aug  6 18:04:23 2014
;; MSG SIZE  rcvd: 42

我應該對綁定區域文件進行哪些更改以使其看起來盡可能接近 dnsmasq 設置?

想通了,必須進行以下更改:

添加minimal-responses yes;named.conf.options

並將區域文件更改為以下內容:

$TTL    3600
$ORIGIN override-url.example.com.

@       IN SOA override-url.example.com. hostmaster.override-url.example.com. (
       20140805 ; sn = serial number
       86400    ; ref = refresh = 1d
       900      ; ret = update retry = 15m
       1209600  ; ex = expiry = 2w
       3600     ; min = minimum = 1h
       )

       ; we need at least 1 name server
       IN NS override-url.example.com.

       ; override public ip with this address
       IN A 54.210.127.53

引用自:https://serverfault.com/questions/618550