named.conf の include文を view で囲んでみる、どうなるか?

1. view 構文を使用する


先日、BIND 9 の named.conf で view 構文を使用する機会が あった

その際に BIND の設定を再読込せしめると、

/etc/init.d/bind9 reload
Reloading bind9 configuration (via systemctl): bind9.serviceJob for bind9.service failed. See 'systemctl status bind9.service' and 'journalctl -xn' for details.

failed!

どうやら失敗した らしい
systemctl status bind9.service を見てみろ、と あるので実行して見ると、

● bind9.service - BIND Domain Name Server

Loaded: loaded (/lib/systemd/system/bind9.service; enabled)

Drop-In: /run/systemd/generator/bind9.service.d

mq50-insserv.conf-$named.conf

Active: active (running) (Result: exit-code) since 金 2015-06-05 07:26:13 JST; 1 weeks 0 days ago

Docs: man:named(8)

Process: 1111 ExecReload=/usr/sbin/rndc reload (code=exited, status=1/FAILURE)

Main PID: 440 (named)

CGroup: /system.slice/bind9.service

mq440 /usr/sbin/named -f -u bind

6月 12 22:21:17 senri named[440]: received control channel command 'reload'
6月 12 22:21:17 senri named[440]: loading configuration from '/etc/bind/named.conf'
6月 12 22:21:17 senri named[440]: /etc/bind/named.conf.default-zones:2: when using...ews
6月 12 22:21:17 senri named[440]: reloading configuration failed: failure
6月 12 22:21:17 senri rndc[1111]: rndc: 'reload' failed: failure
6月 12 22:21:17 senri systemd[1]: bind9.service: control process exited, code=exit...s=1
6月 12 22:21:17 senri systemd[1]: Reload failed for BIND Domain Name Server.

Hint: Some lines were ellipsized, use -l to show in full.

どうやら行表示が省略されて ... に されて しまっている
表示末行の Hint を見る限りでは、systemctl status bind9.service に -l を付けて実行すると省略されずに済む らしい
それで、-l は何処(どこ) に付ければ良いのか?

と言う訳(わけ)で、以下を各々実行して見た所、結果は全て同じと なった

systemctl -l status bind9.service
systemctl status -l bind9.service
systemctl status bind9.service -l

どうやら何処に -l を置いても良い らしいが、意外と大雑把では ある

● bind9.service - BIND Domain Name Server

Loaded: loaded (/lib/systemd/system/bind9.service; enabled)

Drop-In: /run/systemd/generator/bind9.service.d

mq50-insserv.conf-$named.conf

Active: active (running) (Result: exit-code) since 金 2015-06-05 07:26:13 JST; 1 weeks 0 days ago

Docs: man:named(8)

Process: 1111 ExecReload=/usr/sbin/rndc reload (code=exited, status=1/FAILURE)

Main PID: 440 (named)

CGroup: /system.slice/bind9.service

mq440 /usr/sbin/named -f -u bind

6月 12 22:21:17 senri named[440]: received control channel command 'reload'
6月 12 22:21:17 senri named[440]: loading configuration from '/etc/bind/named.conf'
6月 12 22:21:17 senri named[440]: /etc/bind/named.conf.default-zones:2: when using 'view' statements, all zones must be in views
6月 12 22:21:17 senri named[440]: reloading configuration failed: failure
6月 12 22:21:17 senri rndc[1111]: rndc: 'reload' failed: failure
6月 12 22:21:17 senri systemd[1]: bind9.service: control process exited, code=exited status=1
6月 12 22:21:17 senri systemd[1]: Reload failed for BIND Domain Name Server.

ついでに journalctl -xn も試して見ると、

journalctl -xn

-- Logs begin at 金 2015-06-05 07:26:09 JST, end at 金 2015-06-12 22:23:58 JST. --

6月 12 22:21:17 senri named[440]: loading configuration from '/etc/bind/named.conf'
6月 12 22:21:17 senri named[440]: ^[[1;31m/etc/bind/named.conf.default-zones:2: when using 'view' statements, all zones must be in views^[[0m
6月 12 22:21:17 senri named[440]: ^[[1;31mreloading configuration failed: failure^[[0m
6月 12 22:21:17 senri rndc[1111]: rndc: 'reload' failed: failure
6月 12 22:21:17 senri systemd[1]: ^[[1;39mbind9.service: control process exited, code=exited status=1^[[0m
6月 12 22:21:17 senri systemd[1]: ^[[1;31mReload failed for BIND Domain Name Server.^[[0m

-- Subject: Unit bind9.service has finished reloading its configuration
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit bind9.service has finished reloading its configuration
--
-- The result is failed.
~
~
~
(stdin):

テキストエディタ(昔のラインエディタ?) の様(よう)な状態と なり、ファイルが開かれた ままで停止する
操作上どう する事も出来ないので、已(や)むを得ず q で この画面を抜ける

何やら制御コードの表示が変で あるが、文中の省略は無い
気に なる部分は、

/etc/bind/named.conf.default-zones:2: when using 'view' statements, all zones must be in views

の箇所で ある

Debian 標準の bind9 に附属する named.conf は、始めから以下の様に記述されている

include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";

ここの named.conf.local ファイル内に view 構文を記述したので あるが、その際には named.conf.default-zones を含む全てのゾーン定義に view を適用しなければ ならない と言う事らしい

成程(なるほど)、そう言うものですか…



2. named.conf.default-zones にも view を適用、しかし…


/etc/bind/named.conf.default-zones に view を記述して いなかったので、view の適用対象と すべく /etc/bind/named.conf.default-zones を編集する

cd /etc/bind/
cp -p named.conf.default-zones named.conf.default-zones.org

vi named.conf.default-zones

変更前

// prime the server with knowledge of the root servers
zone "." {

type hint;
file "/etc/bind/db.root";

};

変更後

// prime the server with knowledge of the root servers

acl default-zones { 192.168.0.0/24;

127.0.0.1;

};

view "default-zones" {

match-clients { default-zones; };

zone "." {

type hint;
file "/etc/bind/db.root";

};

- 省略 -

};

と変更して、これで どうなるかと試して見ると、

/etc/init.d/bind9 reload

どうやら今度は正常に再読み込みが行われた らしい
これで named.conf.default-zones にも view が適用された事に なる

しかし、思うので あるが、標準で用意されている zone ファイルを編集すると言うのは、何と無く落ち着かないものでは ある
何とか ならないものかと考慮していると……



3. named.conf の include に view を適用してみると、さて どうなるのか?


と言う訳で、思い付いた事を早速試して見た

mv named.conf.default-zones.org named.conf.default-zones
cp -p named.conf named.conf.[日付か何か]

vi named.conf

変更前

include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";

変更後

include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
view "default-zones" {
include "/etc/bind/named.conf.default-zones";

match-clients { default-zones; };

};

acl default-zones { 192.168.0.0/24;

127.0.0.1;

};

こう言った反則に近い事が出来るのかと訝(いぶか)しみ ながら試して見ると、

/etc/init.d/bind9 reload

どうやら問題無く再読み込みが出来て しまった...
成程、そう言うものですか...

ならば と思い、更に試して見る

変更後

include "/etc/bind/named.conf.options";
view "internal-zones" {
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";

match-clients { internal-zones; };

};

acl internal-zones { 192.168.0.0/24;

127.0.0.1;

};

named.conf.local と named.conf.default-zones を同じ internal-zones view で囲んで しまおうと言う事で ある
当然の事で あるが、named.conf.local からは view と acl を削除して おく

さて、今度は どうなるか

/etc/init.d/bind9 reload

...呆気(あっけ)無く再読み込みが行われて しまった…
成程、そう言うもの ですか...

なお、上記は これを試した時点での結果で あって、bind9 としての正しい動作で あるのか は分からない
version が更新されれば無効と なるかも知れない

公開 : 2015年6月13日
戻る
pagetop