我注意到在我的配置中,我有很多以这种方式定义的区域:
zone "123.123.123.123.in-addr.arpa" in { type master; file "123.123.123.123"; }; zone "123.123.123.124.in-addr.arpa" in { type master; file "123.123.123.124"; }; zone "example.com" in { type master; file "example.com"; }; zone "example.net" in { type master; file "example.net"; }; // With another ~20 definitions like that
这对我来说似乎效率很低.有没有一种方法可以自动加载找到目录{directory“/ some / folder”}所指定目录的所有文件,并假设每个文件都有主?
解决方法
其他选项可以在全局选项块中设置其默认值(allow-transfer,also-notify等),但您仍然难以定义每个区域和必填字段.
为了完整起见,我会提到BIND的新版本的一个例外,我强烈建议不要这样做.你可以使用新的rndc addzone功能来动态远程创建一个区域,但是它真正做的是创建一个带有散列名称的附加配置文件(即文件名中的随机字符)和一个BIND“知道”的.nzf后缀载入.从可维护性的角度来看,这是非常糟糕的,因为它违反了principle of least surprise/astonishment;主配置文件不引用这些附加配置文件,其他管理员不知道这些文件的内容是否被加载,除非他们熟悉该功能. (而且非常的DNS管理员是因为它的新颖性)
07001
addzone zone [class [view]] configuration
Add a zone while the server is running. This command requires the
allow-new-zones option to be set to yes. The configuration string
specified on the command line is the zone configuration text that
would ordinarily be placed in named.conf.The configuration is saved in a file called hash.nzf,where hash is a
cryptographic hash generated from the name of the view. When named is
restarted,the file will be loaded into the view configuration,so
that zones that were added can persist after a restart.This sample addzone command would add the zone example.com to the
default view:$rndc addzone example.com ‘{ type master; file “example.com.db”; };’
(Note the brackets and semi-colon around the zone configuration text.)
See also rndc delzone and rndc modzone.