天天看點

DNS主從伺服器中域(zone)檔案類型不一緻問題的解決方法

公司的DNS伺服器做了主從配置,最近在使用從伺服器解析的時候,發現莫名其妙的解析不了,經過反複的檢查,配置沒有發現任何問題,在看域檔案的時候,發現有亂碼,問題應該就是出在這裡了。通過file指令檢視了一番,主伺服器的域檔案類型是text,從伺服器的檔案類型是data。

經過查閱官方資料,BIND9的域檔案支援以其他格式讀取或備份,raw格式是目前可用的一個附加格式,使用file指令檢視檔案類型顯示是data,使用raw格式主要是為了提高加載速度。raw格式的域檔案可以通過named-compilezone指令來進行轉換,進而達到編輯的目的,這樣操作顯然比較麻煩了。

In addition to the standard textual format, BIND 9 supports the ability to read or dump to zone files in other formats. The raw format is currently available as an additional format. It is a binary format

representing BIND 9’s internal data structure directly, thereby remarkably improving the loading time.

For a primary server, a zone file in the raw format is expected to be generated from a textual zone file

by the named-compilezone command. For a secondary server or for a dynamic zone, it is automatically

generated (if this format is specified by the masterfile-format option) when named dumps the zone

contents after zone transfer or when applying prior updates.

If a zone file in a binary format needs manual modification, it first must be converted to a textual form by

the named-compilezone command. All necessary modification should go to the text file, which should then be converted to the binary form by the named-compilezone command again.

Although the raw format uses the network byte order and avoids architecture-dependent data alignment

so that it is as much portable as possible, it is primarily expected to be used inside the same single

In order to export a zone file in the raw format or make a portable backup of the file, it is

to convert the file to the standard textual representation.

1 . 在上面的資料中,仔細閱讀masterfile-format這一行,似乎有了新的思路。

2 . 修改從伺服器相關的配置檔案(/etc/named.conf ),添加如下一行:

3 . 重新開機從伺服器:

4 . 過幾秒檢視slave目錄下的域檔案内容,是否跟主伺服器一緻。