mosakabe @ ウィキ
DNSサーバ構築
最終更新:
mosakabe
-
view
BIND9 でローカルDNSサーバを構築します。
BIND9をインストールします。
$ sudo apt-get install bind9
Reading package lists... Done
Building dependency tree
Reading state information... Done
...(省略)...
Not creating home directory `/var/cache/bind'.
wrote key file "/etc/bind/rndc.key"
#
* Starting domain name service... bind9
[ OK ]
ネットワークアドレスを192.168.11.0/24、ルータのIPアドレスが192.168.11.1、ルータが DNS Proxy になっているとします。
/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;
// };
auth-nxdomain no; # conform to RFC1035
listen-on-v6 { any; };
allow-query{
127.0.0.1;
192.168.11.0/24;
};
allow-recursion{
127.0.0.1;
192.168.11.0/24;
};
allow-transfer{
127.0.0.1;
192.168.11.0/24;
};
forwarders{
192.168.11.1;
};
};
次に、ローカルのゾーンを設定するために、/etc/bind/named.conf.local を編集します。
ここではドメインを totto.local とします。
ここではドメインを totto.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 "totto.local" {
type master;
file "/etc/bind/totto.local";
};
zone "11.168.192.in-addr.arpa" {
type master;
file "/etc/bind/11.168.192.in-addr.arpa";
};
最後にゾーンファイルを作成します。
正引き /etc/bind/totto.local
$TTL 86400
@ IN SOA totto.local. ns.totto.local.(
2011102700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
;
IN NS ns.totto.local.
IN A 192.168.11.1
ns IN A 192.168.11.1
www IN A 192.168.11.100
google IN A 74.125.31.106
逆引き /etc/bind/11.168.192.in-addr.arpa
$TTL 86400
@ IN SOA shiten.info. ns.totto.local.(
2011102700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS ns.totto.local.
100 IN PTR www.totto.local.
BIND9 を再起動します。
$ sudo /etc/init.d/bind9 restart
* Stopping domain name service... bind9
[ OK ]
* Starting domain name service... bind9
[ OK ]
各サーバのDNSを変更するために /etc/resolv.conf を編集します。
nameserver 192.168.11.100 search totto.local
search に totto.local を指定したことで、ネットワーク内ではwww.totto.local を www だけで引くことができます。
/etc/resolv.conf を編集した場合は、 networking を再起動します。
$ sudo /etc/init.d/networking restart
* Reconfiguring network interfaces...
ssh stop/waiting
ssh start/running, process 3287
[ OK ]
最後に nslookup で反映されているか確認します。
$ nslookup www Server: 192.168.11.100 Address: 192.168.11.100#53 Name: www.totto.local Address: 192.168.11.100
以下広告