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

BIND - list of forwarders used on several zones

· 52CE 我爱测

I am setting up a BIND (v9.16) nameserver. Its main purpose is to work as a regular recursor for our internal hosts. For a couple of specific zones though (the ones that we host), I need to set it up as a forwarder. The goal is t…

问题原文

原帖链接 · Patrick Aszody · CC BY-SA 4.0

I am setting up a BIND (v9.16) nameserver.

Its main purpose is to work as a regular recursor for our internal hosts. For a couple of specific zones though (the ones that we host), I need to set it up as a forwarder. The goal is to avoid creating a dependency on root and TLD DNS servers, and being able to continue using our internal services even in the case of unavailability of our outside network connections.

This was easy to setup, here the relevant parts of my configuration :

options {
    allow-recursion {
        // Here comes the list of our inside networks
    };

};

zone "somedomain.example" IN {
    type forward;
    forward first;
    forwarders {
        // Here comes the list of the primary servers for this zone
    };
// ... repeated for all forward zones

This setup works as expected, but with a minor inconvenience. The list of primary servers has to be repeated for all the "forward" zones. We have quite a few of them, all with IPv4 and IPv6 addresses, and ^C/^V the list to all zones is not the most elegant thing I have seen, nor is it very DRY-compliant.

I know that the forwarders statement can also be included in the global options section, but from basic experiments I understand that this statement does not apply to forward zones, it is only meant for a forward-only nameserver (the documentation is not crystal-clear, but mentions that "if no forwarders statement is present, [...] cancelling the effects of any forwarders in the options statement").

Is there a way to create a named list of forwarders, more or less the same way we create ACLs, and use this symbolic name in the forwarders statement inside relevant zones ?

已采纳解答

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

Like many other daemons and services ISC Bind supports an include directive in its configuration files.

That allows you to move a list of configuration settings and directives to a different file, and you can reference that include where it's needed.

That reduces your administrative burden to only maintaining your list of forwarders in a single place and you only need to copy the reference where it is needed.

// "/var/named/includes/forwarders.conf"
// master list of forwarders

forwarders {
            192.0.2.21;
            192.0.2.88;
};

and then in you named.conf:

zone "somedomain.example" IN {
    type forward;
    forward first;
    include "/var/named/includes/forwarders.conf";
}
zone "otherdomain.example" IN {
    type forward;
    forward first;
    include "/var/named/includes/forwarders.conf";
}

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

资料来源与适用范围

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

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

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