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
system. In order to export a zone file in the raw format or make a portable backup of the file, it is
recommended to convert the file to the standard textual representation.

(二)解决方法

1 . 在上面的资料中,仔细阅读masterfile-format这一行,似乎有了新的思路。
2 . 修改从服务器相关的配置文件(/etc/named.conf ),添加如下一行:

masterfile-format text ;

3 . 重启从服务器:

systemctl restart named

4 . 过几秒查看slave目录下的域文件内容,是否跟主服务器一致。

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值