まずは、宅内機器に対してrasberry piのアドレス解決をさせるべく、name serverを建てます。当面はrasberry piを外部公開しないのでHome GWでのport forwardingや外向けname serverへの登録はやりません。
ここではws9.orgのmaster name serverの位置付けで、外部公開しているname serverに登録している総ての情報、および宅内向けの情報を登録します。また、宅内サーバーもMXは外部に向けて、メールはgw.ws9.orgで受け取るようにします。
apt-get install bind9でbindを入れると/etc/bindにconfiguration fileが配置されます。
pi@raspie /etc/bind $ ls ./ db.127 db.root named.conf.options ../ db.255 named.conf named.conf.options.orig bind.keys db.ws9.org named.conf.default-zones rndc.key db.0 db.empty named.conf.local zones.ws9.org db.1.168.192 db.local named.conf.local.orig zones.rfc1918 pi@raspie /etc/bind $
設定し終わった後のディレクトリの状態。変更する前の元ファイルを.origに別名保存してます。
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"; include "/etc/bind/zones.ws9.org"; ←自ドメイン定義ファイルの追加
zones.ws9.orgの作成
zone "ws9.org" { type master; file "/etc/bind/db.ws9.org"; }; zone "1.168.192.in-addr.arpa" { type master; file "/etc/bind/db.1.168.192"; };
ドメインのマスターとして正引き・逆引きを登録します。
db.ws9.orgの作成
$TTL 86400 @ IN SOA ws9.org. root.ws9.org.( 1 ; Serial 28800 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Minimum IN NS raspie.ws9.org. IN A 49.212.170.162 IN MX 10 gw.ws9.org. gw IN A 49.212.170.162 IN MX 10 gw.ws9.org. blog IN CNAME gw.ws9.org. hgw IN A 192.168.1.1 wlan IN A 192.168.1.2 nas IN A 192.168.1.5 raspie IN A 192.168.1.8 IN MX 10 gw.ws9.org. home IN CNAME raspie.ws9.org.
ws9.orgの外向けname serverに登録されている総ての正引き情報と宅内機器の正引き情報を登録します。rasberry piは本名raspie.ws9.org、別名home.ws9.org、MXはgw.ws9.orgに向けます。
db.1.168.192の作成
; ; BIND reverse data file for broadcast zone ; $TTL 86400 @ IN SOA ws9.org. root.ws9.org. ( 1 ; Serial 28800 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Negative Cache TTL IN NS ws9.org. 1 IN PTR hgw.ws9.org. 2 IN PTR wlan.ws9.org. 5 IN PTR nas.ws9.org. 8 IN PTR raspie.ws9.org.
プライベートアドレスで動いている宅内機器の逆引き情報を登録します。グローバルアドレスで動いてる機器の逆引きは外部向けname serverに任せます。
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; // }; forwarders { ←追加。ここに登録されていない正引き・逆引きはルーターに任せる 192.168.1.1; }; //======================================================================== // If BIND logs error messages about the root key being expired, // you will need to update your keys. See https://www.isc.org/bind-keys //======================================================================== dnssec-enable no; // dnssec-validation auto; ←ちゃんと設定しないとログがうるさいので dnssec-validation no; DNS SecをDisableに設定 auth-nxdomain no; # conform to RFC1035 listen-on-v6 { any; }; };
他のファイルは変更する必要ありません。この状態で
pi@raspie ! /etc/init.d/bind9 start pi@raspie ! update-rc.d bind9 enable
してname serviceを動かしておきます。