DNSマスター(プライマリ)を構築したら、必ず用意しておきたいのが、スレーブ(セカンダリ)です。同じサーバー内に設置するのは意味がありませんので、マスターとスレーブは別々のサーバーに構築します。マスター側の設定が終わっている事を前提に進めていきます。
ゾーン転送許可設定(マスター側作業)
# vi /etc/bind/named.conf.options を修正します。
options {
directory "/var/cache/bind";
// If there is a firewall between you and nameservers you want
// to talk to, you may need to fix the firewall to allow multiple
// ports to talk. See http://www.kb.cert.org/vuls/id/800113
// If your ISP provided one or more IP addresses for stable
// nameservers, you probably want to use them as forwarders.
// Uncomment the following block, and insert the addresses replacing
// the all-0's placeholder.
// forwarders {
// 0.0.0.0;
// };
allow-query { 127.0.0.1; 192.168.0.0/24; };
// 追加:ゾーン転送要求を許可するスレーブ側のIPアドレスを指定。
allow-transfer { 127.0.0.1; 192.168.0.0/24; };
also-notify { 192.168.0.101; };
allow-recursion { 127.0.0.1; 192.168.0.0/24; };
version "unknown";
auth-nxdomain no; # conform to RFC1035
listen-on-v6 { none; };
};
設定ファイルの再読み込み(マスター側)
// 設定ファイル読み込む。 # rndc reload
BIND9(DNS)をインストール(スレーブ側)
// インストール # apt-get install bind9
ゾーン追加(スレーブ側)
# vi /etc/bind/named.conf を修正します。
// This is the primary configuration file for the BIND DNS server named.
//
// Please read /usr/share/doc/bind9/README.Debian.gz for information on the
// structure of BIND configuration files in Debian, *BEFORE* you customize
// this configuration file.
//
// If you are just adding zones, please do that in /etc/bind/named.conf.local
include "/etc/bind/named.conf.options";
// prime the server with knowledge of the root servers
zone "." {
type hint;
file "/etc/bind/db.root";
};
// be authoritative for the localhost forward and reverse zones, and for
// broadcast zones as per RFC 1912
zone "localhost" {
type master;
file "/etc/bind/db.local";
};
zone "127.in-addr.arpa" {
type master;
file "/etc/bind/db.127";
};
zone "0.in-addr.arpa" {
type master;
file "/etc/bind/db.0";
};
zone "255.in-addr.arpa" {
type master;
file "/etc/bind/db.255";
};
// 追記:正引きゾーン転送を定義(必要なドメインの数だけ追加してください。)
zone "example.com" {
type slave;
file "/etc/bind/slave/example.com";
masters { 192.168.168.100; };
allow-query { any; };
};
// 追記:逆引きゾーン転送を定義
zone "0.168.192.in-addr.arpa" {
type slave;
file "/etc/bind/slave/0.168.192.in-addr.arpa";
masters { 192.168.168.100; };
allow-query { any; };
};
include "/etc/bind/named.conf.local";
オプション設定
# vi /etc/bind/named.conf.options を修正します。
options {
directory "/var/cache/bind";
// If there is a firewall between you and nameservers you want
// to talk to, you may need to fix the firewall to allow multiple
// ports to talk. See http://www.kb.cert.org/vuls/id/800113
// If your ISP provided one or more IP addresses for stable
// nameservers, you probably want to use them as forwarders.
// Uncomment the following block, and insert the addresses replacing
// the all-0's placeholder.
// forwarders {
// 0.0.0.0;
// };
// 追加:名前解決の問い合わせ元の制限する。
allow-query { 127.0.0.1; 192.168.0.0/24; };
// 追加:ゾーン転送要求を許可するスレーブ側のIPアドレスを指定。
allow-transfer { none; };
// 追加:キャッシュの利用を制限。DNSキャッシュポイズニング対策
allow-recursion { 127.0.0.1; 192.168.0.0/24; };
// 追加:BINDのバージョン情報隠蔽。セキュリティ対策
version "unknown";
auth-nxdomain no; # conform to RFC1035
-listen-on-v6 { any; };
+listen-on-v6 { none; }; ← 変更:IPv6無効に変更。
};
IPv6無効にする(スレーブ側)
IPv6を使わない場合のみ無効にして下さい。
// 編集 # vi /etc/default/bind9 // 内容 # run resolvconf? RESOLVCONF=yes # startup options for the server -OPTIONS="-u bind" +OPTIONS="-u bind -4" ← 変更:IPv4に限定する。
設定ファイルの再読み込み(スレーブ側)
/etc/bind/slaveを作成して、所有権をbindに変更してから再読み込みを行う。/etc/bind/にゾーン定義ファイルを転送させるには、/etc/bind/の所有権をbindに変更する必要がある。
// 保存先ディレクトリ作成 # mkdir /etc/bind/slave // 所有権変更 # chown bind. /etc/bind/slave // 設定反映 # rndc reload
動作チェック(スレーブ側)
// 正引き # dig @192.168.0.101 example.com // 逆引き # dig @192.168.0.101 -x 192.168.0.100
@192.168.0.101 は、今回設定したスレーブのIPを指定すること。
これで情報が引ければ設定完了です。
