Ubuntu でシリアルコンソール

初めての障害対応でシリアルコンソールを使う機会があったのですが、
実機につないで操作する環境が整っていなくてあたふたしてしまったのでメモ。

以下の環境を用意して練習してみました。

たぶんUpstart、GRUB2のUbuntu環境では共通だと思います。

0. 実験環境

Server
OS: Ubuntu Server 11.10
HW:HP ProLiant ML115 G5

Client
OS: Ubuntu Desktop 12.04 LTS Beta2
HW:Lenovo ThinkPad X220

1. サーバ側の準備

大体どのOSもデフォルトではシリアルコンソールの設定がされていないようです。
Ubuntu 11.10は結構簡単に設定ができます。

シリアルポートが /dev/ttyS0 であること、root で操作することを前提に書いていきます。

 

ttyS0.conf を編集(ファイルがないので新しく作る)

root@ml115:/# vi /etc/init/ttyS0.conf

ttyS0.conf にコピペする内容

# ttyS0 – getty
#
# This service maintains a getty on ttyS0 from the point the system is
# started until it is shut down again.

start on stopped rc or RUNLEVEL=[2345]
stop on runlevel [!2345]

respawn
exec /sbin/getty -L 9600 ttyS0 vt102

ttyS0を立ち上げる

root@ml115:/etc/init# sudo start ttyS0
ttyS0 start/running, process 1784

GRUBが起動時にシリアルコンソールに落ちるようにする。

root@ml115:/# vi /etc/default/grub

赤字が追記箇所

root@ml115:~# diff /etc/default/grub.20120427 /etc/default/grub
12c12
< GRUB_CMDLINE_LINUX=””

> GRUB_CMDLINE_LINUX=”console=tty1 console=ttyS0,9600n8″
20a21,22
> GRUB_TERMINAL=serial
> GRUB_SERIAL_COMMAND=”serial –speed=9600 –unit=0 –word=8 –parity=no –stop=1″

変更を適用する

root@ml115:/# update-grub
Generating grub.cfg …
Found linux image: /boot/vmlinuz-3.0.0-12-server
Found initrd image: /boot/initrd.img-3.0.0-12-server
Found memtest86+ image: /memtest86+.bin
done

再起動する

root@ml115:/# shutdown -r now

サーバ側はこれで完了。

2. クライアント側の準備

クライアント側は minicom というソフトウェアを使って接続してみましょう。

まずは minicom のインストール

root@thinkpadx220:~# apt-get install minicom

インストールが終わったら初回起動の設定を済ませておきましょう。

root@thinkpadx220:~# minicom -s

+—–[configuration]——+
| Filenames and paths      |
| File transfer protocols  |
| Serial port setup        |
| Modem and dialing        |
| Screen and keyboard      |
| Save setup as dfl        |
| Save setup as..          |
| Exit                     |
| Exit from Minicom        |
+————————–+

Serial port setup  を選択

+———————————————————————–+
| A –    Serial Device      : /dev/ttyUSB0                              |
| B – Lockfile Location     : /var/lock                                 |
| C –   Callin Program      :                                           |
| D –  Callout Program      :                                           |
| E –    Bps/Par/Bits       : 9600 8N1                                  |
| F – Hardware Flow Control : No                                        |
| G – Software Flow Control : No                                        |
|                                                                       |
|    Change which setting?                                              |
+———————————————————————–+

Serial Device や Bps/Par/Bits  あたりを自分の環境に合わせて設定しましょう。
編集が終わったらEnterで画面を抜けてトップメニューのでSave setup as dflを選択。

これでクライアント側の設定は終了です。
サーバとクライアントをシリアルケーブルで接続してテストしてみましょう。

root@thinkpadx220:~# minicom

Welcome to minicom 2.5

OPTIONS: I18n
Compiled on May  2 2011, 10:05:24.
Port /dev/ttyUSB0

Press CTRL-A Z for help on special keys

Ubuntu 11.10 ml115 ttyS0

ml115 login: AT S7=45 S0=0 L1 V1 X4 &c1 E1 Q0
Password:

CTRL-A Z for help |  9600 8N1 | NOR | Minicom 2.5    | VT102 | Online 00:00

とこんな感じでつながるはずです。

しかし、自分の場合は前提の知識がなかったために一筋縄にはいかず、ここまでくるのに結構苦労しました。
ここからがメモの本番。

4. シリアルコンソールにつながらない(補足1)

ググると大体上記の手順がかかれているのですが実はつながらないはずです。
sudo できる一般ユーザが操作する前提で補足をまとめておきます。

まず、デバイスがroot以外のユーザで使えるか確認。

yutaro@thinkpadx220:~$ ls -al /dev/ttyUSB0
crw-rw—- 1 root dialout 188, 0  4月 22 18:37 /dev/ttyUSB0
yutaro@thinkpadx220:~$

dialoutというグループに許可されているんですね。
操作するユーザをdialoutグループに加えます。

yutaro@thinkpadx220:~$ sudo adduser yutaro dialout

これでminicomを起動すればつながるはずです。

しかし、私はこれだけでは終わらなかったのです。

5. シリアルコンソールにつながらない(補足2)

前提の知識がなかったのでここが一番時間がかかりました。

サーバとクライアントを接続(物理)するにに以下のような方法をとりました。

|サーバ|←[RS232C・RJ-45変換]→[UTPストレートケーブル]←[RS232C・RJ-45変換]→[RS232C・USBアダプタ]→|クライアント|

しかし、いくらいじってもつながらない・・・
何だろなとググっていたらナイスな記事を発見。

ヘタレな趣味人の呟き : Sun シリアル接続用 UTP クロスケーブル

そうなのか。UTPケーブルでシリアルコンソール繋ぐときはクロスケーブルを使うのか。
しまかもクロスケーブルといっても100BASE-TXとか1000BASE-TとかのEthernetの
クロスケーブルとは異なりほんとにピンアサインが逆転したケーブルを使うんですね・・・

シリアル接続用UTPクロスケーブルのピンアサイン

Pin 1 Pin 8
Pin 2 Pin 7
Pin 3 Pin 6
Pin 4 Pin 5
Pin 5 Pin 4
Pin 6 Pin 3
Pin 7 Pin 2
Pin 8 Pin 1

ようはEthernetのストレートケーブルの片方の頭を逆向きにつけたケーブルを作ればいいわけです。
そしてこんな時のために買っておいた秘密兵器。

これでケーブルを作ったらあっけなくシリアルコンソールに接続できました。

本番のクリティカルな障害じゃなくてよかったww
私はまだ一人じゃ何もできませんが、一つ大きな収穫を得ました!

参考文献・資料

Ubuntu UserDocumentation : SerialConsoleHowto

negi.ipv6labs.jp : Linuxシリアルコンソール

ヘタレな趣味人の呟き : Sun シリアル接続用 UTP クロスケーブル

BIND9とAAAAレコードと私(追記あり)

自分のBlogを自宅サーバに移転していてDNSのゾーンファイルを弄っていたのですが変な挙動をしたのでメモします。

バージョンはUbuntuのパッケージ最新版の

sakura# named -v
BIND 9.7.0-P1
sakura#

です。

IPv6ユーザとしてはAレコードよりAAAAレコードが好きなので以下のようにゾーンを定義しました。

 

ゾーンファイル(Before)

sakura# cat yutarommx.com.zone
$TTL   180
@               IN SOA  yutarommx.com.  yutaro.mykw.jp. (
2012041506     ; serial (d. adams)
3H             ; refresh
15M            ; retry
1W             ; expiry
15M)           ; minimum

IN NS           ns0.mykw.jp.
IN NS           ns1.mykw.jp.

IN AAAA         240f:1:33f2:1::beef
www             IN AAAA         240f:1:33f2:1::beef
IN A            124.214.243.203
www             IN A            124.214.243.203

tumblr          IN A            72.32.231.8

そうしたところ、家のPCからはBlogが見えるのですが、リモートで繋いでいた会社(IPv4)から閲覧ができないorz
何だろなとおもい、自宅サーバから dig してみたところ、以下のような結果が。

AAAAレコードの結果(Before)

micro# dig @ns0.mykw.jp yutarommx.com aaaa

; <<>> DiG 9.7.0-P1 <<>> @ns0.mykw.jp yutarommx.com aaaa
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51434
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 4
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;yutarommx.com.                 IN      AAAA

;; ANSWER SECTION:
yutarommx.com.          180     IN      AAAA    240f:1:33f2:1::beef

;; AUTHORITY SECTION:
yutarommx.com.          180     IN      NS      ns1.mykw.jp.
yutarommx.com.          180     IN      NS      ns0.mykw.jp.

;; ADDITIONAL SECTION:
ns0.mykw.jp.            180     IN      A       49.212.22.200
ns0.mykw.jp.            180     IN      AAAA    2001:e41:31d4:16c8::1
ns1.mykw.jp.            180     IN      A       183.181.172.61
ns1.mykw.jp.            180     IN      AAAA    2001:2e8:603:0:2:1:0:3d

;; Query time: 15 msec
;; SERVER: 2001:e41:31d4:16c8::1#53(2001:e41:31d4:16c8::1)
;; WHEN: Sun Apr 15 12:08:35 2012
;; MSG SIZE  rcvd: 190

Aレコードの結果(Before)

micro# dig @ns0.mykw.jp yutarommx.com a

; <<>> DiG 9.7.0-P1 <<>> @ns0.mykw.jp yutarommx.com a
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50777
;; flags: qr aa rd; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;yutarommx.com.                 IN      A

;; AUTHORITY SECTION:
yutarommx.com.          180     IN      SOA     yutarommx.com. yutaro.mykw.jp. 2012041509 10800 900 604800 900

;; Query time: 15 msec
;; SERVER: 2001:e41:31d4:16c8::1#53(2001:e41:31d4:16c8::1)
;; WHEN: Sun Apr 15 12:08:30 2012
;; MSG SIZE  rcvd: 81

むむ!!?

Aレコードが引けてない・・・・
ということで以下のように書き換えてみたところ・・・

 

ゾーンファイル(Before2)

sakura# cat yutarommx.com.zone
$TTL   180
@               IN SOA  yutarommx.com.  yutaro.mykw.jp. (
2012041510     ; serial (d. adams)
3H             ; refresh
15M            ; retry
1W             ; expiry
15M)           ; minimum

IN NS           ns0.mykw.jp.
IN NS           ns1.mykw.jp.

IN A            124.214.243.203
www             IN A            124.214.243.203
IN AAAA         240f:1:33f2:1::beef
www             IN AAAA         240f:1:33f2:1::beef

tumblr          IN A            72.32.231.8

AAAAレコードの結果(Before2)

 

micro# dig @ns0.mykw.jp yutarommx.com aaaa

; <<>> DiG 9.7.0-P1 <<>> @ns0.mykw.jp yutarommx.com aaaa
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12
;; flags: qr aa rd; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;yutarommx.com.                 IN      AAAA

;; AUTHORITY SECTION:
yutarommx.com.          180     IN      SOA     yutarommx.com. yutaro.mykw.jp. 2012041510 10800 900 604800 900

;; Query time: 15 msec
;; SERVER: 2001:e41:31d4:16c8::1#53(2001:e41:31d4:16c8::1)
;; WHEN: Sun Apr 15 12:29:57 2012
;; MSG SIZE  rcvd: 81

Aレコードの結果(Before2)

micro# dig @ns0.mykw.jp yutarommx.com a

; <<>> DiG 9.7.0-P1 <<>> @ns0.mykw.jp yutarommx.com a
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37995
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 4
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;yutarommx.com.                 IN      A

;; ANSWER SECTION:
yutarommx.com.          180     IN      A       124.214.243.203

;; AUTHORITY SECTION:
yutarommx.com.          180     IN      NS      ns0.mykw.jp.
yutarommx.com.          180     IN      NS      ns1.mykw.jp.

;; ADDITIONAL SECTION:
ns0.mykw.jp.            180     IN      A       49.212.22.200
ns0.mykw.jp.            180     IN      AAAA    2001:e41:31d4:16c8::1
ns1.mykw.jp.            180     IN      A       183.181.172.61
ns1.mykw.jp.            180     IN      AAAA    2001:2e8:603:0:2:1:0:3d

;; Query time: 15 msec
;; SERVER: 2001:e41:31d4:16c8::1#53(2001:e41:31d4:16c8::1)
;; WHEN: Sun Apr 15 12:29:41 2012
;; MSG SIZE  rcvd: 178

 

今度はAAAAレコードが返ってこない・・・
次にサブドメイン(FQDN)を揃えつつAレコードを優先して定義してみた。

ゾーンファイル(After)

sakura# cat yutarommx.com.zone
$TTL   180
@               IN SOA  yutarommx.com.  yutaro.mykw.jp. (
2012041507     ; serial (d. adams)
3H             ; refresh
15M            ; retry
1W             ; expiry
15M)           ; minimum

IN NS           ns0.mykw.jp.
IN NS           ns1.mykw.jp.

IN A            124.214.243.203
IN AAAA         240f:1:33f2:1::beef
www             IN A            124.214.243.203
www             IN AAAA         240f:1:33f2:1::beef

tumblr          IN A            72.32.231.8

AAAAレコードの結果(After)

micro# dig @ns0.mykw.jp yutarommx.com a

; <<>> DiG 9.7.0-P1 <<>> @ns0.mykw.jp yutarommx.com
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62064
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 4
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;yutarommx.com.                 IN      A

;; ANSWER SECTION:
yutarommx.com.          180     IN      A       124.214.243.203

;; AUTHORITY SECTION:
yutarommx.com.          180     IN      NS      ns1.mykw.jp.
yutarommx.com.          180     IN      NS      ns0.mykw.jp.

;; ADDITIONAL SECTION:
ns0.mykw.jp.            180     IN      A       49.212.22.200
ns0.mykw.jp.            180     IN      AAAA    2001:e41:31d4:16c8::1
ns1.mykw.jp.            180     IN      A       183.181.172.61
ns1.mykw.jp.            180     IN      AAAA    2001:2e8:603:0:2:1:0:3d

;; Query time: 16 msec
;; SERVER: 2001:e41:31d4:16c8::1#53(2001:e41:31d4:16c8::1)
;; WHEN: Sun Apr 15 12:39:01 2012
;; MSG SIZE  rcvd: 178

Aレコードの結果(After)

micro# dig @ns0.mykw.jp yutarommx.com aaaa

; <<>> DiG 9.7.0-P1 <<>> @ns0.mykw.jp yutarommx.com aaaa
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64265
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 4
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;yutarommx.com.                 IN      AAAA

;; ANSWER SECTION:
yutarommx.com.          180     IN      AAAA    240f:1:33f2:1::beef

;; AUTHORITY SECTION:
yutarommx.com.          180     IN      NS      ns1.mykw.jp.
yutarommx.com.          180     IN      NS      ns0.mykw.jp.

;; ADDITIONAL SECTION:
ns0.mykw.jp.            180     IN      A       49.212.22.200
ns0.mykw.jp.            180     IN      AAAA    2001:e41:31d4:16c8::1
ns1.mykw.jp.            180     IN      A       183.181.172.61
ns1.mykw.jp.            180     IN      AAAA    2001:2e8:603:0:2:1:0:3d

;; Query time: 16 msec
;; SERVER: 2001:e41:31d4:16c8::1#53(2001:e41:31d4:16c8::1)
;; WHEN: Sun Apr 15 12:39:21 2012
;; MSG SIZE  rcvd: 190

micro#

今度はちゃんと返ってきた。

教訓:FQDNはソートしてAAAAレコードはAレコードより後に書こう!(Aレコードを併記する場合)

これって昔の公務員より融通が利かないなw

この辺の挙動はバンディー君に期待しましょう。

 

追記

ブログを投稿した後に某JP〇〇の @OrangeMorishita 氏からご指摘がございました。
以下、引用文

これ、正しい動作なんじゃないかな。INの前の名前を省略した場合、*直前の行の*継続行になります。
なので、beforeの例ではIN A 124.214.243.203はwwwの継続行だし、before2の例ではIN AAAA 240f:1:33f2:1::beefはwwwの継続行になります。

なるほど、INの前を省略すると勝手にOriginのドメインが補完されると思っていたのですが、
そうではなく空白の場合は前の行の内容を引き継ぐとのことだそうです。

ということは、こんな書き方もできるということですね!

sakura# cat yutarommx.com.zone
$TTL   180
@               IN SOA  yutarommx.com.  yutaro.mykw.jp. (
2012041513     ; serial (d. adams)
3H             ; refresh
15M            ; retry
1W             ; expiry
15M)           ; minimum

IN NS           ns0.mykw.jp.
IN NS           ns1.mykw.jp.

IN AAAA         240f:1:33f2:1::beef
IN A            124.214.243.203

www                     IN A            124.214.243.203
IN AAAA         240f:1:33f2:1::beef

tumblr                  IN A            72.32.231.8
sakura#

 

ほんとにこんなんで大丈夫なのかなと思いながら dig してみると。

wktk# dig @ns0.mykw.jp yutarommx.com a +short
124.214.243.203

wktk# dig @ns0.mykw.jp yutarommx.com aaaa +short
240f:1:33f2:1::beef

wktk# dig @ns0.mykw.jp http://www.yutarommx.com a +short
124.214.243.203

wktk# dig @ns0.mykw.jp http://www.yutarommx.com aaaa +short
240f:1:33f2:1::beef

お!ちゃんと引けているではないですか!

ゾーンファイルの内容がわかりづらいのでわかってないと気持ち悪いけど、
ルールがわかってすっきりしました。

森下氏 ありがとうございました!

お家でUnboundつかってISPのDNSポイズニングから逃れてみる

数年前の話題だが、児童ポルノ法の施工に伴って、ISPのDNSキャッシュ汚染が常習的に行われるようになったのですが、
そんな自由を侵すようなリゾルバは使ってられないということ(嘘)で自宅にもUnboundを導入してみました。

※本当は自宅サービスサーバのユーザが増えてきたので、何となくLAN内でリゾルバを持ちたくなっただけ。

0. 運用環境

OS : Ubuntu 10.04 LTS
HW : HP Proliant MicroServer

1. apt-get で インストール

ゆとり世代なのでapt-getでインストール。
apt 簡単でいいね。

micro# apt-get install unbound

2. ルートヒントファイルをダウンロードしておく

これがないと、どこに聞きに行くのかわからない。はず。(なくても名前解決できたけどね。)

micro# cd /etc/unbound && wget ftp://FTP.INTERNIC.NET/domain/named.cache

3. confを目的・環境に合わせて書き換える

自分の場合は自宅内のローカルからのみ名前解決できるようするのが目的だったので、
以下の箇所を書き換えた。ちなみにIPv6を使わない場合はv6系の項目は無視しておk

micro# diff -u unbound.conf.def unbound.conf
— unbound.conf.def    2012-04-14 16:33:20.268064334 +0900
+++ unbound.conf        2012-04-14 16:47:19.748193075 +0900
@@ -34,7 +34,10 @@
# specify 0.0.0.0 and ::0 to bind to all available interfaces.
# specify every interface[@port] on a new ‘interface:’ labelled line.
# The listen interfaces are not changed on reload, only on restart.
–       # interface: 192.0.2.153
+       interface: 127.0.0.1
+       interface: 192.168.0.128
+       interface: ::1
+       interface: 240f:1:33f2:1::cafe
# interface: 192.0.2.154
# interface: 192.0.2.154@5003
# interface: 2001:DB8::5
@@ -44,7 +47,7 @@
# interface-automatic: no

# port to answer queries from
–       # port: 53
+       port: 53

# specify the interfaces to send outgoing queries to authoritative
# server from by ip-address. If none, the default (all) interface
@@ -116,7 +119,7 @@

# the time to live (TTL) value cap for RRsets and messages in the
# cache. Items are not cached for longer. In seconds.
–       # cache-max-ttl: 86400
+       cache-max-ttl: 86400

# the time to live (TTL) value for cached roundtrip times and
# EDNS version information for hosts. In seconds.
@@ -137,16 +140,16 @@
# infra-cache-lame-size: 10k

# Enable IPv4, “yes” or “no”.
–       # do-ip4: yes
+       do-ip4: yes

# Enable IPv6, “yes” or “no”.
–       # do-ip6: yes
+       do-ip6: yes

# Enable UDP, “yes” or “no”.
–       # do-udp: yes
+       do-udp: yes

# Enable TCP, “yes” or “no”.
–       # do-tcp: yes
+       do-tcp: yes

# Detach from the terminal, run in background, “yes” or “no”.
# do-daemonize: yes
@@ -157,9 +160,11 @@
# Choose deny (drop message), refuse (polite error reply),
# allow (recursive ok), allow_snoop (recursive and nonrecursive ok)
# access-control: 0.0.0.0/0 refuse
–       # access-control: 127.0.0.0/8 allow
+       access-control: 127.0.0.0/8 allow
+       access-control: 192.168.0.0/24 allow
# access-control: ::0/0 refuse
–       # access-control: ::1 allow
+       access-control: ::1 allow
+       access-control: 240f:1:33f2:1::0/64 allow
# access-control: ::ffff:127.0.0.1 allow

# if given, a chroot(2) is done to the given directory.
@@ -214,7 +219,7 @@

# file to read root hints from.
# get one from ftp://FTP.INTERNIC.NET/domain/named.cache
–       # root-hints: “”
+       root-hints: “/etc/unbound/named.cache”

# enable to not answer id.server and hostname.bind queries.
# hide-identity: no
@@ -437,27 +442,27 @@
remote-control:
# Enable remote control with unbound-control(8) here.
# set up the keys and certificates with unbound-control-setup.
–       # control-enable: no
+       control-enable: yes

# what interfaces are listened to for remote control.
# give 0.0.0.0 and ::0 to listen to all interfaces.
–       # control-interface: 127.0.0.1
–       # control-interface: ::1
+       control-interface: 127.0.0.1
+       control-interface: ::1

# port number for remote control operations.
–       # control-port: 953
+       control-port: 953

# unbound server key file.
–       # server-key-file: “/etc/unbound/unbound_server.key”
+       server-key-file: “/etc/unbound/unbound_server.key”

# unbound server certificate file.
–       # server-cert-file: “/etc/unbound/unbound_server.pem”
+       server-cert-file: “/etc/unbound/unbound_server.pem”

# unbound-control key file.
–       # control-key-file: “/etc/unbound/unbound_control.key”
+       control-key-file: “/etc/unbound/unbound_control.key”

# unbound-control certificate file.
–       # control-cert-file: “/etc/unbound/unbound_control.pem”
+       control-cert-file: “/etc/unbound/unbound_control.pem”

# Stub zones.
# Create entries like below, to make all queries for ‘example.com’ and
micro#

4. リモートコントロールできるようにする

unbound-control を使えるようにするために秘密鍵、公開鍵を生成。
unbound-control は BIND でいうところの rndc ですね。

# unbound-control-setup
setup in directory /etc/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
micro#

5. Unboundを再起動する

micro# /etc/init.d/unbound restart
* Restarting recursive DNS server unbound                                                                       [ OK ]
micro#

6. 名前解決ができるか確認

とりあえずローカルホストから確認。
LAN内のほかのホストからも確認した方が良い。

micro# dig @localhost mykw.jp

; <<>> DiG 9.7.0-P1 <<>> @localhost mykw.jp
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 13101
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 4

;; QUESTION SECTION:
;mykw.jp.                       IN      A

;; ANSWER SECTION:
mykw.jp.                180     IN      A       180.222.80.63

;; AUTHORITY SECTION:
mykw.jp.                180     IN      NS      ns0.mykw.jp.
mykw.jp.                180     IN      NS      ns1.mykw.jp.

;; ADDITIONAL SECTION:
ns0.mykw.jp.            180     IN      A       49.212.22.200
ns0.mykw.jp.            180     IN      AAAA    2001:e41:31d4:16c8::1
ns1.mykw.jp.            180     IN      A       183.181.172.61
ns1.mykw.jp.            180     IN      AAAA    2001:2e8:603:0:2:1:0:3d

;; Query time: 15 msec
;; SERVER: ::1#53(::1)
;; WHEN: Sat Apr 14 17:00:02 2012
;; MSG SIZE  rcvd: 165

micro#

7. リモートコントロールの動作確認

ステータスが取れれば成功

micro# unbound-control status
version: 1.4.1
verbosity: 1
threads: 1
modules: 2 [ validator iterator ]
uptime: 4 seconds
unbound (pid 5050) is running…
micro#

 

これでISPのDNSポイズニングから抜け出せますね。

めでたしめでたし

 

参考資料・サイト

日本Unboundユーザ会 http://unbound.jp/