[精讚] [會員登入]

Bind9 工作目錄沒設對,竟然也不報錯的詭異邏輯

其實這是報怨文,因為我為此浪費了4小時和很多腦細胞除錯

分享完整連結 //n.sfs.tw/m10604

分享連結 Bind9 工作目錄沒設對,竟然也不報錯的詭異邏輯@精讚
(文章歡迎轉載,請尊重版權註明連結來源)
2019-08-12 02:30:39 By 張○○

今天弄Freebsd 系統中的BIND9(BIND 9.11.8 OS FreeBSD 11.2-RELEASE-p10)

遇到兩個詭異的問題,第一個我覺得根本就是個混蛋玩意,

抱怨一

事情是這樣的,在他提供的設定檔範例(named.conf.sample)中有這樣的說明,為了怕有人英文不好懶得看,我特別用綠字翻翻譯:

/*      Serving the following zones locally will prevent any queries
        for these zones leaving your network and going to the root
        name servers.  This has two significant advantages:
        1. Faster local resolution for your users
        2. No spurious traffic will be sent from your network to the roots

簡單的來說就是設定一些黑洞網域(blackhole zone),防止這些查詢造成根網域的困擾,還能加速你的使用者查詢速度。
*/
// RFCs 1912, 5735 and 6303 (and BCP 32 for localhost)
zone "localhost"        { type master; file "/usr/local/etc/namedb/master/localhost-forward.db"; };
zone "127.in-addr.arpa" { type master; file "/usr/local/etc/namedb/master/localhost-reverse.db"; };
zone "255.in-addr.arpa" { type master; file "/usr/local/etc/namedb/master/empty.db"; };

// RFC 1912-style zone for IPv6 localhost address (RFC 6303)
zone "0.ip6.arpa"       { type master; file "/usr/local/etc/namedb/master/localhost-reverse.db"; };

// "This" Network (RFCs 1912, 5735 and 6303)
zone "0.in-addr.arpa"   { type master; file "/usr/local/etc/namedb/master/empty.db"; };

// Private Use Networks (RFCs 1918, 5735 and 6303)
zone "10.in-addr.arpa"     { type master; file "/usr/local/etc/namedb/master/empty.db"; };
zone "16.172.in-addr.arpa" { type master; file "/usr/local/etc/namedb/master/empty.db"; };
zone "17.172.in-addr.arpa" { type master; file "/usr/local/etc/namedb/master/empty.db"; };
zone "18.172.in-addr.arpa" { type master; file "/usr/local/etc/namedb/master/empty.db"; };
zone "19.172.in-addr.arpa" { type master; file "/usr/local/etc/namedb/master/empty.db"; };
zone "20.172.in-addr.arpa" { type master; file "/usr/local/etc/namedb/master/empty.db"; };
zone "21.172.in-addr.arpa" { type master; file "/usr/local/etc/namedb/master/empty.db"; };
zone "22.172.in-addr.arpa" { type master; file "/usr/local/etc/namedb/master/empty.db"; };
zone "23.172.in-addr.arpa" { type master; file "/usr/local/etc/namedb/master/empty.db"; };
zone "24.172.in-addr.arpa" { type master; file "/usr/local/etc/namedb/master/empty.db"; };
zone "25.172.in-addr.arpa" { type master; file "/usr/local/etc/namedb/master/empty.db"; };
zone "26.172.in-addr.arpa" { type master; file "/usr/local/etc/namedb/master/empty.db"; };
zone "27.172.in-addr.arpa" { type master; file "/usr/local/etc/namedb/master/empty.db"; };
zone "28.172.in-addr.arpa" { type master; file "/usr/local/etc/namedb/master/empty.db"; };
zone "29.172.in-addr.arpa" { type master; file "/usr/local/etc/namedb/master/empty.db"; };
...

只是設定檔,還有很多大概200個我略過 ....

真是厲害了我的國好棒棒我馬上就高潮了,可是當我心歡喜悅的啟動的時後,他竟然向我報錯:

咦?!明明是你的範例耶…

service named restart
named not running? (check /var/run/named/pid).
/usr/local/etc/namedb/named.conf:1029: writeable file '/usr/local/etc/namedb/master/localhost-reverse.db': already in use: /usr/local/etc/namedb/named.conf:1025
/usr/local/etc/namedb/named.conf:1032: writeable file '/usr/local/etc/namedb/master/empty.db': already in use: /usr/local/etc/namedb/named.conf:1026
/usr/local/etc/namedb/named.conf:1035: writeable file '/usr/local/etc/namedb/master/empty.db': already in use: /usr/local/etc/namedb/named.conf:1026
/usr/local/etc/namedb/named.conf:1036: writeable file '/usr/local/etc/namedb/master/empty.db': already in use: /usr/local/etc/namedb/named.conf:1026
/usr/local/etc/namedb/named.conf:1037: writeable file '/usr/local/etc/namedb/master/empty.db': already in use: /usr/local/etc/namedb/named.conf:1026
/usr/local/etc/namedb/named.conf:1038: writeable file '/usr/local/etc/namedb/master/empty.db': already in use: /usr/local/etc/namedb/named.conf:1026
/usr/local/etc/namedb/named.conf:1039: writeable file '/usr/local/etc/namedb/master/empty.db': already in use: /usr/local/etc/namedb/named.conf:1026
/usr/local/etc/namedb/named.conf:1040: writeable file '/usr/local/etc/namedb/master/empty.db': already in use: /usr/local/etc/namedb/named.conf:1026

只是一樣的錯誤,不同的是行號,還有很多大概200個我略過 ....

我馬上就意識到他說,你一個檔案只能給一個ZONE用,多的不可以。

花了三個小時找解決方案,失敗

明明以前在linux 都是正常,一個檔案可以給很多個ZONE使用,到這裡就不行??

我放棄,

只好使出大絕招:註解。

 

抱怨二

這和上面一樣,經由上面的經驗,我知道系統在啟動的時候,會去查找你的ZONE檔有沒有被重覆使用。

嗯嗯,我做了筆記

所以當我設定一個正常的檔案的時候,由上面和以前的經驗,我以為,他肯定會去檢查我的檔案

然後我就快樂的啟動服務了,後來發現我的記錄都沒有回應?

明明我的記錄都寫得很正常,

我用的named-checkzone, named-checkconf他都說很OK

馬的,最後才發現我的工作目錄沒有設定正確

directory       "/usr/local/etc/namedb";

 

明明我的ZONE檔都不存在你都讀不到了,竟然沒有報錯,這是怎樣?

剛剛重覆不行,現在沒有卻可以,什麼邏輯

明明在linux 都是正常,到這裡就不行??

浪費我一小時在找錯…

 

因為很氣,氣到我寫這篇

END
你可能有興趣

check-host 從世界各地檢查你的網站能不能連線?

檢測你的網站能不能暢通?這個網站可讓你知道你的網站是不是「網際網路」還是「區域網路」?

[Smarty4] 出現 modifiers 函式不能用的問題

當我把smarty由3版更新到4.5.1版的時候,出現了Using unregistered function xx in a template這樣的錯誤,該如何解決?

[Docker] docker中要怎麼修改影像的名稱,rename image

透過 build來的image如果沒有指定名稱,事後要怎麼修改影像的名稱?

[Rocky9] 安裝node.js 18, node.js 20

原本的nodejs16在使用 quasar dev時出現錯誤,得升級成18版以上

[SSL] Could not read certificate from server.cer 的錯誤排除

在轉換ssl憑證時,出現無法讀取的錯誤,可是怎麼看憑證都很正常,該怎麼解決?

[Linux] 如何能知道我是什麼時候安裝系統的?

linux想知道什麼時候裝系統的?什麼時候建置的?不必憑記憶。