Ubuntuにbind9をセットアップしたメモ
infoScoopのテスト用にbindのセットアップをした際のメモです。
前置きですが、OpenSocialのコンテナの多くは、クロスサイトスクリプトの問題を回避するために、各ガジェットが表示されるiframeを別々のドメインで動作させています。
前回のjavascriptのサニタイズの記事で紹介したcajaプロジェクトには、ガジェットを別々のドメインで動作させなくてもクロスドメインのセキュリティを解決することができるようですが、とりあえずはinfoScoopは、前者の方法でクロスドメインを解決することにしました。
(この機能は2.1で実装します。現在リリースされている2.0では、2つのドメインでしか別けられません)
この機能を利用するには、ワイルドカードで名前解決する設定をDNSに追加する必要があります。テスト用にbindをセットアップしたので最小限の手順を覚書としてまとめておきます。
サーバーの構成は、以下のように仮定します。
- ドメイン:infoscoop.test
- プライマリーDNSサーバーIPアドレス:192.168.1.1
- bindをインストールするマシンのIPアドレス:192.168.1.10
- infoScoopのサーバーのIPアドレス:192.168.1.20
bindをインストールするサーバーはUbuntu 9.10で試しました。
bindの設定1 named.conf
$ sudo vi /etc/bind/named.conf.options
プライマリーDNSサーバーへのフォワードだけ追加しておきます。
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. auth-nxdomain no; # conform to RFC1035 listen-on-v6 { any; }; forwarders { 192.168.1.1; }; };
bindの設定2 ゾーンファイル
xxxx.infoscoop.testのリクエストは全部infoScoopサーバー(192.168.1.20)に解決するように設定します。
sudo vi /etc/bind/db.infoscoop.test
$TTL 604800 @ IN SOA localhost. root.localhost. ( 2007112701; Serial 604800; Refresh 86400; Retry 2419200; Expire 604800 ); Negative Cache TTL ; @ IN NS ns.infoscoop.test IN A 192.168.1.10 * IN A 192.168.1.20
infoScoopを動かすだけでしたら、逆引きはいらない気がしますが、一応設定。
$ sudo vi /etc/bind/db.192.168.1
$TTL 604800 @ IN SOA localhost. root.localhost.( 20091118; Serial 604800; Refresh 86400; Retry 2419200; Expire 604800 ); Negative Cache TTL ; @ IN NS ns.infoscoop.test 10 IN PTR infoscoop.test 20 IN PTR gadget.infoscoop.test
bindの設定3 named.conf
作成したゾーンファイルをnamed.confに指定します。
$ sudo vi /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 "dev.lc" { type master; file "/etc/bind/db.dev.lc"; };2011/02/24修正 zone "infoscoop.test" { type master; file "/etc/bind/db.infoscoop.test"; }; zone "192.168.1.in-addr.arpa" { type master; file "/etc/bind/db.192.168.1"; };
bindの再起動
最後にbindを再起動すれば設定完了です。
$ sudo /etc/init.d/bind9 restart
DNSサーバー設定の変更
DNS設定も変更しておきます。
$ sudo vi /etc/resolv.conf
domain infoscoop.test search infoscoop.test nameserver 192.168.1.10 nameserver 192.168.1.1
設定を確認
$ nslookup gadget.infoscoop.test Server: infoscoop.test.1.168.192.in-addr.arpa Address: 192.168.1.10 Name: gadget.infoscoop.test Address: 192.168.1.20 $ nslookup gadget2.infoscoop.test Server: infoscoop.test.1.168.192.in-addr.arpa Address: 192.168.1.10 Name: gadget.infoscoop.test Address: 192.168.1.20
ちゃんと、ワイルドカードで1つのホストに解決されています。