事前確認事項

インストール

aptitude install dnsutils bind9 bind9-doc

dnsutils
bind9なくてもいれるべき

rndc
ローカルホスト又はリモートホストからのnamed デーモンのコマンドライン管理が出来る

マニュアル

bind9-docを入れると

/usr/share/doc/bind9-doc/arm以下にBv9ARM.html

にあるのでwebページとして表示させるようにApache2の設定に追加する

設定の種類

  1. 順引きゾーンテーブル:ホスト名からIPアドレスを探す。debian.or.jp->218.223.29.46とか
  2. 逆引きゾーンテーブル:IPアドレスからホスト名を探す。
  3. ルートヒントファイル:インターネット上に準備されているルートサーバーの一覧ファイル

順引き

  • localhost -> /etc/bind/db.localが担当
    逆引き
  • localhost -> /etc/bind/db.127, /etc/bind/db.0, /etc/bind/db.255が担当。
    ルートヒント
  • /etc/bind/db.rootが担当。/etc/bind/named.confに書いてあるので、特に両ファイルとも触る必要なし

構成としては
named.conf

  1. include "/etc/bind/named.conf.options";
  2. include "/etc/bind/named.conf.local";
    1. include "/etc/bind/rndc.key";
      といった感じ。

設定箇所

自宅サーバでの設定方法

通常の設定方法

/etc/bind$ sudo rndc-confgen -r /dev/random > rndc.conf

# Start of rndc.conf
key "rndc-key" {
	algorithm hmac-md5;
	secret "ごにょごにょ=";
};

options {
	default-key "rndc-key";
	default-server 127.0.0.1;
	default-port 953;
};
# End of rndc.conf
# Use with the following in named.conf, adjusting the allow list as needed:
# key "rndc-key" {
# 	algorithm hmac-md5;
# 	secret "ごにょごにょ=";
# };
# 
#  controls {
# 	inet 127.0.0.1 port 953
# 		allow { 127.0.0.1; } keys { "rndc-key"; };
# };
# End of named.conf

chown bind:bind rndc.conf
chmod 600 rndc.conf

/etc/bind/named.conf

....

/etc/bind/named.conf.options

options {
...
    version "DNS Server" #追加する
    recursion yes; #キャッシュサーバの場合 yes
    allow-transfer { none; }; #zoneの転送はしない(BIND9のdefaultは制限がかかってない)
}

/etc/bind/named.conf.local
先ほど作ったrndc.confの#の部分を持ってきて貼り付ける

# Use with the following in named.conf, adjusting the allow list as needed:
key "rndc-key" {
 	algorithm hmac-md5;
 	secret "axdGqNFdPQWWuNQ6jrBnww==";
 };
 
  controls {
 	inet 127.0.0.1 port 953
 		allow { 127.0.0.1; } keys { "rndc-key"; };
 };
# End of named.conf
#zone情報を追加する
zone "example.jp" {
      type master;
      file "/etc/bind/db.example.jp";
       allow-query { any; }
};

/etc/bind/db.example.jp

設定を元に戻す方法

rndc-confgen > /etc/bind/rndc.conf

とすると

key "rndc-key" {
        algorithm hmac-md5;
	 secret "ごにょごにょしたの";
};
options {
        default-key "rndc-key";
        default-server 127.0.0.1;
        default-port 953;
};

といった物が出来る。

キャッシュのみのネームサーバーにする方法

LAN内や社内などのみに使われる場合など。外部からの要求には拒否をする。

acl "corpnets" { 
 192.168.4.0/24;  //社内とかのIP
 192.168.7.0/24;  //上記に同じ
};
options {
     directory "/var/cache/bind";           // Working directory
     pid-file "named.pid";              // Put pid file in working dir
     allow-query { "corpnets"; };
};
// ルートサーバーのヒント
zone "." { 
 type hint; 
 file "root.hint"; 
};
// 127.0.0.1のループバック際の情報をあげる
zone "0.0.127.in-addr.arpa" {
     type master;
     file "localhost.rev";
     notify no;
};

rndcで管理する方法

まずはrndcを起動する

/usr/sbin/rndc *restart

rndcのオプション

  • reload:設定ファイルとzoneファイルの更新を行う。
  • reload zone [class [view]]:一つのzoneファイルの更新を行う
  • refresh zone [class [view]] : zoneのリフレッシュ(メンテナンス、再読み込み?)を行う。
  • reconfig :設定ファイルと新しいzoneファイルの読み込みを行う。
  • stats : Write server statistics to the statistics file.
  • querylog Toggle query logging.
  • dumpdb Dump cache(s) to the dump file (named_dump.db).
  • stop Save pending updates to master files and stop the server.
  • halt Stop the server without saving pending updates.
  • trace Increment debugging level by one.
  • trace level Change the debugging level.
  • notrace Set debugging level to 0.
  • flush Flushes all of the server's caches.
  • flush [view] Flushes the server's cache for a view.
  • status Display status of the server.
  • *restart Restart the server.

rndcを使う為には設定をしないと行けない。具体的には/etc/bind/rndc.keyに下記のような行が必要(ローカルからの接続)。

controls {
       inet 127.0.0.1 port 953 allow { 127.0.0.1; } keys { "comuro"; };
};

セキュリティ対策

bind9で使えるセキュリティ対策はこちら!
"allow-query"、"allow-transfer"、"allow-update"、"allow-recursion"

確認方法

設定ファイルをチェックしてくれるコマンド
named-checkconf [-v] [ -t directory ] filename

-v : named-checkconfのバージョンを表示

エラー時には

MacでDNSキャッシュをクリアしたい場合は

dscacheutil -flushcache

参考URL

Bind = Berkeley Internet Name Domainの略らしい。Book binderとかをイメージしてた。


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2012-03-12 (月) 16:54:31 (197d)