Unbound 資料一覧
2009/1/17更新
対応バージョン: 1.2.0
unbound-controlを使用するとローカル/リモートのUnboundを操作したり各種統計情報を取得することができる。
以下、設定手順を記す。
SSL証明書作成
ローカル/リモートにかかわらずサーバに接続するにはSSLを利用するのでまずサーバ側でSSLの証明書を作成する。
これにはUnbound付属のunbound-control-setupを使用する。
リモートサーバに接続する場合はリモート側で証明書を作成してローカルにコピーする。
% sudo /usr/local/sbin/unbound-control-setup setup in directory /var/unbound generating unbound_server.key Generating RSA private key, 1024 bit long modulus ................................++++++ ..........++++++ e is 65537 (0x10001) generating unbound_control.key Generating RSA private key, 1024 bit long modulus .................++++++ .........++++++ e is 65537 (0x10001) create unbound_server.pem (self signed certificate) create unbound_control.pem (signed client certificate) Signature ok subject=/CN=unbound-control Getting CA Private Key Setup success. Certificates created. Enable in unbound.conf file to use
証明書は/var/unbound配下に以下の4種類が作成される。
unbound_server.pem
unbound_server.key
サーバの公開鍵証明書(pem)と秘密鍵(key)
unbound_control.pem
unbound_control.key
クライアントの公開鍵証明書(pem)と秘密鍵(key)
公開鍵証明書の内容は以下のコマンドで参照できる。
% sudo openssl x509 -in <ファイル> -text
設定ファイル変更
unbound.confにてremote-controlのcontrol-enableをyesに設定する。
remote-control: control-enable: yes
ローカルサーバに接続する場合はこれだけでよいが、リモートサーバに接続する場合はcontrol-interfaceでサービスをバインドするインタフェースを指定する(デフォルトはループバックインタフェースにバインドするのでリモートからの接続を受け付けない)。
remote-control: control-interface: 192.168.0.100
その他、待ち受けポート、サーバ/クライアントそれぞれの証明書のパスを指定できるのでデフォルト以外の設定にしたい場合は適宜変更する。
サーバ再起動
サーバを再起動し、待ち受けポートに953ポートが追加されていることを確認する。
% sudo service unbound restart % netstat -na|egrep '(Proto|:53|:953)' Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN udp 0 0 127.0.0.1:53 0.0.0.0:*
サーバ接続
サーバへの接続はunbound-controlを使用する。
接続したいサーバを指定して制御コマンドを送ると当該サーバが制御できる(ローカルサーバの場合はサーバは省力可)。
% sudo /usr/local/sbin/unbound-control [-s <サーバ>] <コマンド>
以下、いくつかの制御コマンドの実行例を示す。
status
サーバの稼働状況出力
% sudo /usr/local/sbin/unbound-control status version: 1.2.0 verbosity: 1 threads: 1 modules: 2 [ validator iterator ] uptime: 346 seconds unbound (pid 20434) is running...
stats
統計情報出力
% sudo /usr/local/sbin/unbound-control stats thread0.num.queries=1 thread0.num.cachehits=0 thread0.num.cachemiss=1 thread0.num.recursivereplies=1 thread0.requestlist.avg=0 thread0.requestlist.max=0 thread0.requestlist.overwritten=0 thread0.requestlist.exceeded=0 thread0.requestlist.current.all=0 thread0.requestlist.current.user=0 thread0.recursion.time.avg=0.756473 thread0.recursion.time.median=0 total.num.queries=1 total.num.cachehits=0 total.num.cachemiss=1 total.num.recursivereplies=1 total.requestlist.avg=0 total.requestlist.max=0 total.requestlist.overwritten=0 total.requestlist.exceeded=0 total.requestlist.current.all=0 total.requestlist.current.user=0 total.recursion.time.avg=0.756473 total.recursion.time.median=0 time.now=1232123631.180667 time.up=96.178490 time.elapsed=96.178490
reload
サーバリロード
キャッシュがクリアされ、設定ファイルが再読み込みされる。
% sudo /usr/local/sbin/unbound-control reload ok
lookup
名前解決に使われたネームサーバを表示
% drill www.apple.com ;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 61272 ;; flags: qr rd ra ; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;; www.apple.com. IN A ;; ANSWER SECTION: www.apple.com. 1800 IN CNAME www.apple.com.akadns.net. www.apple.com.akadns.net. 60 IN A 17.149.160.10 ;; AUTHORITY SECTION: ;; ADDITIONAL SECTION: ;; Query time: 903 msec ;; SERVER: 127.0.0.1 ;; WHEN: Sat Jan 17 01:46:38 2009 ;; MSG SIZE rcvd: 85 % sudo /usr/local/sbin/unbound-control lookup www.apple.com The following name servers are used for lookup of www.apple.com. ;rrset 86383 6 0 2 0 apple.com. 172783 IN NS nserver.apple.com. apple.com. 172783 IN NS nserver.asia.apple.com. apple.com. 172783 IN NS nserver.euro.apple.com. apple.com. 172783 IN NS nserver2.apple.com. apple.com. 172783 IN NS nserver3.apple.com. apple.com. 172783 IN NS nserver4.apple.com. ;rrset 86383 1 0 1 0 nserver4.apple.com. 172783 IN A 17.112.144.59 ;rrset 86383 1 0 1 0 nserver3.apple.com. 172783 IN A 17.112.144.50 ;rrset 86383 1 0 1 0 nserver2.apple.com. 172783 IN A 17.254.0.59 ;rrset 86383 1 0 1 0 nserver.euro.apple.com. 172783 IN A 17.72.133.64 ;rrset 86383 1 0 1 0 nserver.asia.apple.com. 172783 IN A 17.82.254.3 ;rrset 86383 1 0 1 0 nserver.apple.com. 172783 IN A 17.254.0.50 Delegation with 6 names, of which 6 have no addresses in cache. It provides 6 IP addresses.
dump_cache
キャッシュ内容出力
<キャッシュがない状態> ... まだ何も名前解決していない状態
% sudo /usr/local/sbin/unbound-control dump_cache START_RRSET_CACHE END_RRSET_CACHE START_MSG_CACHE END_MSG_CACHE EOF
<キャッシュがある状態> ... www.apple.comの名前解決をした状態
% sudo /usr/local/sbin/unbound-control dump_cache START_RRSET_CACHE ;rrset 47 1 0 8 2 www.apple.com.akadns.net. 47 IN A 17.149.160.10 ;rrset 1787 1 0 8 2 www.apple.com. 1787 IN CNAME www.apple.com.akadns.net. ;rrset 86387 1 0 1 0 use4.akadns.net. 172787 IN A 208.44.108.137 ;rrset 86387 1 0 1 0 L.GTLD-SERVERS.NET. 172787 IN A 192.41.162.30 ;rrset 86387 1 0 1 0 F.GTLD-SERVERS.NET. 172787 IN A 192.35.51.30 ;rrset 86387 1 0 1 0 G.GTLD-SERVERS.NET. 172787 IN A 192.42.93.30 ;rrset 86387 1 0 1 0 H.GTLD-SERVERS.NET. 172787 IN A 192.54.112.30 ;rrset 86387 1 0 1 0 B.GTLD-SERVERS.NET. 172787 IN AAAA 2001:503:231d::2:30 ;rrset 86387 13 0 2 0 net. 172787 IN NS L.GTLD-SERVERS.net. net. 172787 IN NS M.GTLD-SERVERS.net. net. 172787 IN NS A.GTLD-SERVERS.net. net. 172787 IN NS B.GTLD-SERVERS.net. net. 172787 IN NS C.GTLD-SERVERS.net. net. 172787 IN NS D.GTLD-SERVERS.net. net. 172787 IN NS E.GTLD-SERVERS.net. net. 172787 IN NS F.GTLD-SERVERS.net. net. 172787 IN NS G.GTLD-SERVERS.net. net. 172787 IN NS H.GTLD-SERVERS.net. net. 172787 IN NS I.GTLD-SERVERS.net. net. 172787 IN NS J.GTLD-SERVERS.net. net. 172787 IN NS K.GTLD-SERVERS.net. ;rrset 86387 1 0 3 0 L.ROOT-SERVERS.NET. 3599987 IN A 199.7.83.42 ;rrset 86387 1 0 3 0 F.ROOT-SERVERS.NET. 3599987 IN A 192.5.5.241 ;rrset 86387 1 0 3 0 H.ROOT-SERVERS.NET. 3599987 IN A 128.63.2.53 ;rrset 86387 1 0 3 0 G.ROOT-SERVERS.NET. 3599987 IN A 192.112.36.4 ;rrset 86387 1 0 3 0 E.ROOT-SERVERS.NET. 3599987 IN A 192.203.230.10 ;rrset 86387 1 0 1 0 nserver.apple.com. 172787 IN A 17.254.0.50 ;rrset 86387 1 0 1 0 nserver.euro.apple.com. 172787 IN A 17.72.133.64 ;rrset 86387 6 0 2 0 apple.com. 172787 IN NS nserver.apple.com. apple.com. 172787 IN NS nserver.asia.apple.com. apple.com. 172787 IN NS nserver.euro.apple.com. apple.com. 172787 IN NS nserver2.apple.com. apple.com. 172787 IN NS nserver3.apple.com. apple.com. 172787 IN NS nserver4.apple.com. ;rrset 86387 13 0 2 0 com. 172787 IN NS L.GTLD-SERVERS.NET. com. 172787 IN NS C.GTLD-SERVERS.NET. com. 172787 IN NS M.GTLD-SERVERS.NET. com. 172787 IN NS G.GTLD-SERVERS.NET. com. 172787 IN NS K.GTLD-SERVERS.NET. com. 172787 IN NS J.GTLD-SERVERS.NET. com. 172787 IN NS A.GTLD-SERVERS.NET. com. 172787 IN NS B.GTLD-SERVERS.NET. com. 172787 IN NS F.GTLD-SERVERS.NET. com. 172787 IN NS I.GTLD-SERVERS.NET. com. 172787 IN NS E.GTLD-SERVERS.NET. com. 172787 IN NS D.GTLD-SERVERS.NET. com. 172787 IN NS H.GTLD-SERVERS.NET. ;rrset 86387 1 0 1 0 eur1.akadns.net. 172787 IN A 195.59.44.134 ;rrset 86387 1 0 1 0 usw2.akadns.net. 172787 IN A 12.183.125.5 ;rrset 86387 1 0 1 0 C.GTLD-SERVERS.NET. 172787 IN A 192.26.92.30 ;rrset 86387 1 0 1 0 D.GTLD-SERVERS.NET. 172787 IN A 192.31.80.30 ;rrset 86387 1 0 1 0 E.GTLD-SERVERS.NET. 172787 IN A 192.12.94.30 ;rrset 86387 1 0 1 0 A.GTLD-SERVERS.NET. 172787 IN AAAA 2001:503:a83e::2:30 ;rrset 86387 1 0 1 0 B.GTLD-SERVERS.NET. 172787 IN A 192.33.14.30 ;rrset 86387 1 0 3 0 L.ROOT-SERVERS.NET. 3599987 IN AAAA 2001:500:3::42 ;rrset 86387 1 0 3 0 I.ROOT-SERVERS.NET. 3599987 IN A 192.36.148.17 ;rrset 86387 1 0 3 0 K.ROOT-SERVERS.NET. 3599987 IN AAAA 2001:7fd::1 ;rrset 86387 1 0 1 0 nserver4.apple.com. 172787 IN A 17.112.144.59 ;rrset 86387 9 0 2 0 akadns.net. 172787 IN NS asia9.akadns.net. akadns.net. 172787 IN NS eur1.akadns.net. akadns.net. 172787 IN NS use3.akadns.net. akadns.net. 172787 IN NS use4.akadns.net. akadns.net. 172787 IN NS usw2.akadns.net. akadns.net. 172787 IN NS za.akadns.org. akadns.net. 172787 IN NS zb.akadns.org. akadns.net. 172787 IN NS zc.akadns.org. akadns.net. 172787 IN NS zd.akadns.org. ;rrset 86387 1 0 1 0 I.GTLD-SERVERS.NET. 172787 IN A 192.43.172.30 ;rrset 86387 1 0 1 0 K.GTLD-SERVERS.NET. 172787 IN A 192.52.178.30 ;rrset 86387 1 0 1 0 A.GTLD-SERVERS.NET. 172787 IN A 192.5.6.30 ;rrset 86387 1 0 3 0 F.ROOT-SERVERS.NET. 3599987 IN AAAA 2001:500:2f::f ;rrset 86387 1 0 3 0 A.ROOT-SERVERS.NET. 3599987 IN AAAA 2001:503:ba3e::2:30 ;rrset 86387 1 0 3 0 A.ROOT-SERVERS.NET. 3599987 IN A 198.41.0.4 ;rrset 86387 1 0 3 0 J.ROOT-SERVERS.NET. 3599987 IN AAAA 2001:503:c27::2:30 ;rrset 86387 1 0 3 0 J.ROOT-SERVERS.NET. 3599987 IN A 192.58.128.30 ;rrset 86387 1 0 3 0 C.ROOT-SERVERS.NET. 3599987 IN A 192.33.4.12 ;rrset 86387 13 0 8 0 . 518387 IN NS L.ROOT-SERVERS.NET. . 518387 IN NS F.ROOT-SERVERS.NET. . 518387 IN NS H.ROOT-SERVERS.NET. . 518387 IN NS I.ROOT-SERVERS.NET. . 518387 IN NS D.ROOT-SERVERS.NET. . 518387 IN NS A.ROOT-SERVERS.NET. . 518387 IN NS G.ROOT-SERVERS.NET. . 518387 IN NS K.ROOT-SERVERS.NET. . 518387 IN NS B.ROOT-SERVERS.NET. . 518387 IN NS J.ROOT-SERVERS.NET. . 518387 IN NS E.ROOT-SERVERS.NET. . 518387 IN NS M.ROOT-SERVERS.NET. . 518387 IN NS C.ROOT-SERVERS.NET. ;rrset 86387 1 0 1 0 nserver3.apple.com. 172787 IN A 17.112.144.50 ;rrset 86387 1 0 1 0 asia9.akadns.net. 172787 IN A 220.73.220.4 ;rrset 86387 1 0 1 0 use3.akadns.net. 172787 IN A 204.2.178.133 ;rrset 86387 1 0 1 0 M.GTLD-SERVERS.NET. 172787 IN A 192.55.83.30 ;rrset 86387 1 0 1 0 J.GTLD-SERVERS.NET. 172787 IN A 192.48.79.30 ;rrset 86387 1 0 3 0 H.ROOT-SERVERS.NET. 3599987 IN AAAA 2001:500:1::803f:235 ;rrset 86387 1 0 3 0 D.ROOT-SERVERS.NET. 3599987 IN A 128.8.10.90 ;rrset 86387 1 0 3 0 K.ROOT-SERVERS.NET. 3599987 IN A 193.0.14.129 ;rrset 86387 1 0 3 0 B.ROOT-SERVERS.NET. 3599987 IN A 192.228.79.201 ;rrset 86387 1 0 3 0 M.ROOT-SERVERS.NET. 3599987 IN AAAA 2001:dc3::35 ;rrset 86387 1 0 3 0 M.ROOT-SERVERS.NET. 3599987 IN A 202.12.27.33 ;rrset 86387 1 0 1 0 nserver.asia.apple.com. 172787 IN A 17.82.254.3 ;rrset 86387 1 0 1 0 nserver2.apple.com. 172787 IN A 17.254.0.59 END_RRSET_CACHE START_MSG_CACHE msg www.apple.com.akadns.net. IN A 32896 1 47 0 1 0 0 www.apple.com.akadns.net. IN A 0 msg www.apple.com. IN A 32896 1 47 2 2 0 0 www.apple.com. IN CNAME 0 www.apple.com.akadns.net. IN A 0 msg . IN NS 32896 1 86387 0 1 0 20 . IN NS 0 A.ROOT-SERVERS.NET. IN A 0 A.ROOT-SERVERS.NET. IN AAAA 0 B.ROOT-SERVERS.NET. IN A 0 C.ROOT-SERVERS.NET. IN A 0 D.ROOT-SERVERS.NET. IN A 0 E.ROOT-SERVERS.NET. IN A 0 F.ROOT-SERVERS.NET. IN A 0 F.ROOT-SERVERS.NET. IN AAAA 0 G.ROOT-SERVERS.NET. IN A 0 H.ROOT-SERVERS.NET. IN A 0 H.ROOT-SERVERS.NET. IN AAAA 0 I.ROOT-SERVERS.NET. IN A 0 J.ROOT-SERVERS.NET. IN A 0 J.ROOT-SERVERS.NET. IN AAAA 0 K.ROOT-SERVERS.NET. IN A 0 K.ROOT-SERVERS.NET. IN AAAA 0 L.ROOT-SERVERS.NET. IN A 0 L.ROOT-SERVERS.NET. IN AAAA 0 M.ROOT-SERVERS.NET. IN A 0 M.ROOT-SERVERS.NET. IN AAAA 0 END_MSG_CACHE EOF
その他のコマンドについては日本Unboundユーザ会のunbound-control(8)を参照のこと。