BIND9 マスターを構築する手順を記録として残しておきます。
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 master;
file "example.com";
allow-query { any; };
allow-update { none; }
};
// 追記:逆引きゾーン情報定義。
zone "0.168.192.in-addr.arpa" {
type master;
file "0.168.192.in-addr.arpa";
allow-query { any; };
allow-update { none; };
};
include "/etc/bind/named.conf.local";
正引きゾーン定義ファイルを作成
// 新規作成
# vi /etc/bind/example.com
// サンプル内容
$TTL 3600
@ IN SOA ns.example.com. root.example.com. (
2011010101 ; Serial
1800 ; Refresh
900 ; Retry
604800 ; Expire
1200 ) ; Minimum
; Name Servers
IN NS ns.example.com.
; Mail
example.com. IN MX 10 mail.example.com.
; Hosts
@ IN A 192.168.0.100
mail IN A 192.168.0.100
www IN A 192.168.0.100
// 説明
$TTL :別のDNSがこの情報をどれくらいの期間キャッシュするかを指定。
Serial :ゾーンファイルの更新をした場合、値を変更しないと設定が反映されない。
Refresh :スレーブがゾーン情報の更新をチェックする間隔。
Retry :スレーブがゾーン転送を失敗した場合に待機する間隔。
Expire :スレーブがゾーンファイルを無効とみなすまでの時間。
Minimum :問い合わせレコードが存在しなかった場合に「存在しない」という情報の生存時間。単位:秒
逆引きゾーン定義ファイルを作成
// 新規作成
# vi /etc/bind/0.168.192.in-addr.arpa
// サンプル内容
$TTL 3600
@ IN SOA ns.example.com. root.example.com. (
2011010101 ; Serial
1800 ; Refresh
900 ; Retry
604800 ; Expire
1200 ) ; Minimum
; Name Servers
IN NS ns.example.com.
; Subnet Mask
IN A 255.255.255.0
; Hosts
100 IN PTR ns.example.com.
100 IN PTR mail.example.com.
100 IN PTR web.example.com.
ゾーン定義ファイルのチェック
named-checkzone [ ゾーン名 ] [ ゾーンファイル ]
// 正引き # named-checkzone example.com /etc/bind/example.com // 逆引き # named-checkzone 0.168.192.in-addr.arpa /etc/bind/0.168.192.in-addr.arpa
オプション設定
// 編集
# 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; };
// 追加:キャッシュの利用を制限。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無効に変更。
};
named.conf 設定ファイルのチェック
// チェック # named-checkconf /etc/bind/named.conf
※ 何も表示されなければOK!
IPv6無効にする
// 編集 # vi /etc/default/bind9 // 内容 # run resolvconf? RESOLVCONF=yes # startup options for the server -OPTIONS="-u bind" +OPTIONS="-u bind -4" ← 変更:IPv4に限定する。
設定ファイルの再読み込み
// リロード # rndc reload
動作チェック
// 正引き # dig @192.168.0.101 example.com // 逆引き # dig @192.168.0.101 -x 192.168.0.100
@192.168.0.101 は、今回設定したDNSマスターのIPを指定すること。
これで情報が引ければ設定完了です。
