玄箱X4/サーバー設定/bind
出典: Fukudat.com
Berkeley Internet Name Domain (BIND), Dynamic Domain Name Service (DDNS)
目次 |
1 インストール
# apt-get install bind9 host
2 設定
まず,/etc/bind ディレクトリを bindグループが書き込みできるようにする.
# ls -ld /etc/bind drwxr-sr-x 2 root bind 4096 Feb 17 14:04 /etc/bind # chmod g+w /etc/bind # ls -ld /etc/bind drwxrwsr-x 2 root bind 4096 Feb 17 14:04 /etc/bind
こうしないとbindというユーザで動いている named (bindのサーバープロセス) がデータベースを更新できないので,Dynamic DNS (DDNS) にならない. このディレクトリにあるファイルも bind group のものにしたほうがよいかも.
/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 {
192.168.0.1;
};
auth-nxdomain no; # conform to RFC1035
listen-on-v6 { any; };
};
ただし,192.168.0.1はブロードバンドルータ.
/etc/bind/named.conf.local を編集.
//
// Do any local configuration here
//
// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";
zone "fukudat.com" {
type master;
file "/etc/bind/db.fukudat.com";
allow-update {
192.168.0.0/24;
127.0.0.1;
};
};
zone "0.168.192.in-addr.arpa" {
type master;
file "/etc/bind/db.0.168.192";
allow-update {
192.168.0.0/24;
127.0.0.1;
};
};
/etc/bind/named.conf.xxx を編集.(xxxはVPNでつながっているプライベートドメイン)
zone "xxx.com" {
type forward;
forwarders { 9.0.4.1; 9.0.5.1; };
};
zone "9.in-addr.arpa" {
type forward;
forwarders { 9.0.4.1; 9.0.5.1; };
};
VPNのネームサーバー(上記では9.0.4.1, 9.0.5.1)へのルーティングがあることを確認.なければ永続的な静的ルーティングを参照して作成.
最後にサービスをリスタート.
# /etc/init.d/bind9 restart
3 コマンドでアドレスを追加する
nsupdateコマンドを使う.
# nsupdate > update delete oldhost.fukudat.com A # oldhost.fukudat.comのAレコードを消去する > update delete 31.0.168.192.in-addr.arpa. IN PTR # 192.168.0.31の逆引きレコードを消去する > update add newhost.fukudat.com 86400 A 192.168.0.51 # newhost.fukudat.comのAレコードをアドレス192.168.0.51で作成する.TTLは1日(86400秒). > send
4 ゾーンファイルを手動で書き換える
静的なアドレスを登録するときゾーンファイル (db.fukudat.com (順引きデータ), db.0.168.192 (逆引きファイル)) を直接書き換えたくなる.そうするならば,*.jnl ファイルに動的な変更の履歴が残っているので,これをフラッシュする必要がある.
# rndc freeze # rndc thaw
そのうえでサーバーをいったん止めて,ゾーンファイルを書き換え,サーバーを再起動する.
# /etc/init.d/bind9 stop # vi /etc/bind/db.fukudat.com ... 書き換え ... # /etc/init.d/bind9 start
5 キャッシュを削除する
WANとのネットワーク接続が切れた時など,存在する名前がnegative listに乗ってしまうことがある. Windowsのローカルキャッシュなら
C\> ipconfig /flushdns
とすればよいが,bind9 の場合は
# rndc flush
とする.
