Bind

通過 dnsmasq 的大 AXFR 導致 dig 掛起並出現部分結果

  • December 19, 2018

我正在嘗試將 dnsmasq 設置為 consul 的本地記憶體。雖然這似乎對正常探勘工作正常,但 dnsmasq 似乎只允許部分區域傳輸。

我的 resolv.conf:

search x.domain.com y.domain.com z.domain.com domain.com
nameserver 127.0.0.1
nameserver 10.0.0.1
nameserver 10.0.0.2
nameserver 10.0.0.3
options timeout: 2 attempts: 3

我的 dnsmasq 設置只是將請求轉發.consul到同一個盒子上的 3000 埠,這是我的領事 dns 埠。否則,我使用 dnsmasq 預設值(它將請求轉發到 resolv.conf 中的其他 dns)。

server=/consul/127.0.0.1#3000 

這適用於正常探勘並從伺服器本地主機返回結果,例如。dig consul.service.consul +short將返回:

10.22.1.15
10.22.1.16
10.22.1.17

正如預期的那樣。普通 DNS(轉發到 BIND dns 伺服器)也可以正常工作,例如。dig host.hosts.domain.com +short將返回10.22.1.23

但是,當進行區域傳輸時dig axfr us1.domain.com,dig 將返回大約 700 行,然後掛起,總是在同一個地方。如果我包括+retry=0dig;; connection timed out; no servers could be reached在 700 行之後的底部放置一個。

從上游(綁定)dns 伺服器進行區域傳輸時,它會按預期返回所有 22k 結果。

為 dig (標誌)打開記憶體調試後,-m它似乎掛在

del 0x7f5c8131e010 size 152 file timer.c line 390 mctx 0x17572d0

當按下 ctrl+c 時,它會吐出一個回溯,我設法追查到 dig 認為請求尚未完成,我認為這是真的:

dighost.c:3831: REQUIRE(sockcount == 0) failed, back trace
#0 0x7f5c802c4227 in ??
#1 0x7f5c802c417a in ??
#2 0x41212d in ??
#3 0x405e0e in ??
#4 0x7f5c7de2f445 in ??
#5 0x405e6e in ??
Aborted (core dumped)

啟用額外的 dnsmasq 日誌記錄後,我可以在 axfr 中看到:

Oct 04 12:17:41 hostname.hosts.domain.com dnsmasq[16055]: forwarded us1.domain.com to 10.0.0.1
Oct 04 12:17:41 hostname.hosts.domain.com dnsmasq[16055]: reply _kerberos.us1.domain.com is DOMAIN.COM
Oct 04 12:17:41 hostname.hosts.domain.com dnsmasq[16055]: reply consul-acl.prod.us1.domain.com is us4

在上游綁定日誌中:

Oct  4 12:20:07 upstreamdns named[17388]: client 10.22.10.20#42228: transfer of 'us1.domain.com/IN': AXFR started
Oct  4 12:20:07 upstreamdns named[17388]: client 10.22.10.20#42228: transfer of 'us1.domain.com/IN': AXFR ended

我懷疑這與最大數據包大小或其他東西有關,但我嘗試了不同記憶體大小的不同設置,以增加 dns 轉發和 edns-packet-max。很奇怪,從上游 dns 請求 axfr 工作正常,但通過 dnsmasq 它只返回部分結果,然後導致 dig 掛起。

編輯:我嘗試了 1.76 版本,並且還編譯了最新的官方送出 7cbf497da4100ea0d1c1974b59f9503e15a0cf80,結果相同。

我正在執行 CentOS Linux 版本 7.5.1804(核心)。

新的消息

在使用/不使用 dnsmasq 進行 tcpdump 之後,我可以看到響應被分成兩個數據包。由於某種原因,dig 在查詢 dnsmasq 時從未收到第二個數據包,所以它只是掛起。數據包的大小分別為 2521 字節和 189 字節,如果這對任何人都有意義的話。

根據 Simon Kelly 教授(dnsmasq 創建者)的說法,這個問題是由超過 65536 字節的區域傳輸引起的,並且 dnsmasq 沒有實現用於將傳輸推送到多個消息中的延續方法。

因此,大區域傳輸將不起作用,建議的解決方法是直接與上游權威伺服器對話。

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