大网数据广告活动
服务器运维问答

Bind 9.10 in-view directive doesn't work

· 52CE 我爱测

Named version: BIND 9.10.3-P4 (the latest one), OS versions: CentOS 6.3 , CentOS 6.7 I need to use shared zones in different views, since 9.10 ISC Bind doesn't support using the same file for the same zone in different views. Try…

问题原文

原帖链接 · Shader · CC BY-SA 3.0

Named version: BIND 9.10.3-P4 (the latest one), OS versions: CentOS 6.3, CentOS 6.7

I need to use shared zones in different views, since 9.10 ISC Bind doesn't support using the same file for the same zone in different views. Trying to do so will lead to an error:

/etc/named.conf:21: writeable file 'slaves/example.db': already in use: /etc/named.conf:8

The documentation suggests using the in-view statement. Brandon Xavier in serverfault recommends the same. However, I failed. Here's simplified configuration file I'm trying to load:

view "internal" {

    zone example.com {
        type slave;
        file "slaves/example.db";
        masters { 192.168.1.1; };
    };

};

view "external" {

    zone example.com {
        in-view "internal";
    };

};

Removing the zone example.com from external view allows named to start. Configuring it to the separate file also works:

zone example.com {
    type slave;
    file "slaves/example2.db";
    masters { 192.168.1.1; };
};

But pointing to a different file is not an option - hereby I provide only example of real configuration. Also when Bind is trying to start, there's no output with an error message nor anything in logs:

# /etc/init.d/named restart
Stopping named:                                            [  OK  ]
Starting named: 
Error in named configuration:
                                                           [FAILED]

Isn't it just nice? Named-checkconf doesn't show any errors (I removed commas or brackets on purpose - checkconf works). I've also taken configuration files from 9.10.3-P4 sources.tar.gz (bin/test/system/..) and the result was the same. Should I report a bug?

已采纳解答

原帖链接 · Shader · CC BY-SA 4.0

Let's take a look on what /usr/sbin/named-checkconf does and returns. The man says: "named-checkconf returns an exit status of 1 if errors were detected and 0 otherwise".

Very well, let's write a script to check return values on a valid named configuration:

#!/bin/bash
/usr/sbin/named-checkconf -z /etc/named.conf >/dev/null 2>&1
echo $?
/usr/sbin/named-checkconf /etc/named.conf >/dev/null 2>&1
echo $?

The output will be 1 and 0. If we place an error in named.conf (e.g. missing semicolon), the results will be 1 and 1. What does it mean? It means the return code is 1 even if there're no errors in configuration but -z key is used - any output is considered as an error. Removing 2>&1 to leave only stderr doesn't have any effect, therefore the easiest temporary fix for this issue is to remove -z option by putting the following directive in /etc/sysconfig/named

DISABLE_ZONE_CHECKING="yes"

P.S. Running the above mentioned script on BIND 9.10.1-RedHat-9.10.1-0.el6 results 0 and 0 on a valid named configuration. And a conclusion: it's a bug in named-checkconf return values, when normal output results 1 return code. Bug with explanation, tests and configuration will be submitted to ISC.

NB! This solution is temporary until fix is implemented. Disabled zone checking won't find errors in zones, missing declaration files, etc. Disable it only if you use in-view directive.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-03-18)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。