Bind †Bind = Berkeley Internet Name Domainの略らしい。Book binderとかをイメージしてた。
インストール †bind9 dnsutils(hostとかdigなどなど便利な道具が入っている) aptitude install dnsutils bind9 bind9-doc マニュアルについて †マニュアルはbind9-docをインストールすると/usr/share/doc/bind9-doc/arm以下にBv9ARM.htmlという名前で入るので、それをどこかweb pageとして見れる場所に動かす。 とこんな感じに見える(全部英語だけど) 設定 †設定の種類
設定
/etc/bind/の下 †構成としては named.conf
自宅サーバの設定 †前提:ドメインはcomuro.org options {
directory "/var/cache/bind";
version "dns server";
auth-nxdomain no; # conform to RFC1035
allow-transfer {
自分のIP;
スレイブNSがあればそのIP;
};
};
acl "SERVERS" {
127.0.0.1;
自分のIP;
スレイブNSがあればそのIP;
};
include "/etc/bind/named.conf.options"
key "rndc-key-ac" {
algorithm hmac-md5;
secret "ごにょごにょ(こんな感じWtGsdf87SQG23=みたいな)";
};
controls {
inet 127.0.0.1 port 953
allow { 127.0.0.1; ;} keys { "rndc-key-ac"; };
};
include "/etc/bind/named.conf.local";
named.conf.local view "internal" {
match-clients {
192.168.1.100(自分のIP);
192.168.1.100(LAN内のIP);
};
省略*
zone "comuro.org" {
type master;
file "/etc/bind/db.comuro.org-inside";
};
zone "1.168.192.in-addr.arpa" {
type master;
file "/etc/bind/db.192.168.1";
};
};
view "external" {
match-clients { any; };
recursion no;
省略*
zone "comuro.org" {
type master;
file "/etc/bind/db.comuro.org";
allow-transfer { SERVERS; };
};
zone "(自分の固定IPの逆).in-addr.arpa" {
type master;
file "/etc/bind/db.(自分の固定IP)";
allow-transfer { SERVERS; };
};
};
include "/etc/bind/rndc.key";
bind9-docからのサンプル設定 †キャッシュのみのネームサーバー 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;
};
named-checkconf †設定ファイルをチェックしてくれるコマンド -v : named-checkconfのバージョンを表示 rndcについて †rndcはBindの「ユーティリティコマンド」だそうです。コマンドなんです。ふむふむ。 まずはrndcを起動させないといけないらしい? /usr/sbin/rndc *restart rndcのオプション
rndcを使う為には設定をしないと行けない。具体的には/etc/bind/rndc.keyに下記のような行が必要(ローカルからの接続)。 controls {
inet 127.0.0.1 port 953 allow { 127.0.0.1; } keys { "comuro"; };
};
余談:設定を元に戻す時は rndc-confgen > /etc/bind/rndc.conf とすると key "rndc-key" {
algorithm hmac-md5;
secret "VRyFS3IOJDwiPkDnGLEi5g==";
};
options {
default-key "rndc-key";
default-server 127.0.0.1;
default-port 953;
};
といった物が出来る。 エラーが出た! †socket.c:1119: internal_send: 192.168.1.100: Invalid argument †症状:dig localhostとすると socket.c:1119: internal_send: 192.168.1.100: Invalid argument と出た。何だろうと思ってman digをするとdigはまず/etc/resolv.confを使うらしい。と言う事はresolv.confが間違っているのでは?と思い修正。 name example.jp search example.jp nameserver 127.0.0.1 nameserver ISP DNS server IP nameserver 192.168.1.110(←これが原因だった。localから自分自身の内部IP192...を見に行くのはおかしい、、) という事でnameserver 192.168.1.100をはずしてdigしたらエラーが出なくなった。 zone 100.1.168.192.in-addr.arpa/IN: loading master file /etc/bind/db.192.168.1.100: not at top of zone †named -u bindとすると/var/log/syslogに上記のようにでた。もしかして必要じゃないじゃ!と思って消したら(当り前だけど)消えた。 not at top of zone †/var/log/syslogに Apr 24 11:16:00 candy named[20421]: zone 0.168.192.in-addr.arpa/IN: loading master file /etc/bind/db.192.168.0: not at top of zone こんなのが!!これは/etc/bind/db.192.168.0に$ORIGIN 0.168.192.in-addr.arpaというのを頭に入れているのが原因でした。 rndc: connect failed: timed out †Stopping domain name service: namedrndc: connect failed: timed out. starting domain name service: named.とエラーが出てしまった。 一旦port 953を外してみたけど違って、ちゃんとrndcの設定が出来てないなら接続エラーが出たのでした。 解決:サブではなく、ディレクトリ単位でDNS設定出来るのか? →出来ない †Q:http://sub.comuro.orgはDNSで簡単に出来そうだけど、http://comuro.org/subで特定のIPに行かせる事は出来るのだろうか?? Nov 16 16:47:01 ns named[426]: lame server resolving 'example.jp' (in 'example.jp'?): XXX.XXX.XXX.XXX#53 †どうやら相手のNSがうまく解決できないようだけど、どうしてログに出るか不明 |