玄箱HGメモ/Debian/DNSキャッシュサーバ導入
緑文字が入力コマンド。
ダイナミックDNSサービス接続後は、外部からはpman10.dyndns.orgから接続できますが、家の中からはKAGUYAで接続する必要がありました。*1
切り分けるのが面倒なので家の中からもpman10.dyndns.orgで接続できるようにDNSキャッシュサーバを導入します。
管理者権限(管理者アカウント参照)で作業する必要があります。
KAGUYA:~# aptitude install dnsmasq[ENTER]
dnsmasq導入画面(例)
Reading package lists... Done Building dependency tree... Done Reading extended state information Initializing package states... Done Reading task descriptions... Done Building tag database... Done The following NEW packages will be automatically installed: dbus libdbus-1-3 libx11-6 libx11-data libxau6 libxdmcp6 x11-common The following NEW packages will be installed: dbus dnsmasq libdbus-1-3 libx11-6 libx11-data libxau6 libxdmcp6 x11-common 0 packages upgraded, 8 newly installed, 0 to remove and 0 not upgraded. Need to get 1911kB of archives. After unpacking 6095kB will be used. Do you want to continue? [Y/n/?]
Y[ENTER]
Writing extended state information... Done Get:1 http://http1.debian.or.jp etch/main x11-common 1:7.1.0-19 [338kB] Get:2 http://security.debian.org etch/updates/main libdbus-1-3 1.0.2-1+etch2 [272kB] Get:3 http://http1.debian.or.jp etch/main libxau6 1:1.0.1-2 [9060B] Get:4 http://http1.debian.or.jp etch/main libxdmcp6 1:1.0.1-2 [12.8kB] Get:5 http://http1.debian.or.jp etch/main libx11-data 2:1.0.3-7 [157kB] Get:6 http://http1.debian.or.jp etch/main libx11-6 2:1.0.3-7 [582kB] Get:7 http://security.debian.org etch/updates/main dbus 1.0.2-1+etch2 [353kB] Get:8 http://security.debian.org etch/updates/main dnsmasq 2.35-1+etch4 [187kB] Fetched 1911kB in 5s (369kB/s) Preconfiguring packages ...
Package configuration lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu Configuring x11-common tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x x x Major possible upgrade issues x x x x Some users have reported that upon upgrade to the current package set, their x x xserver package was no longer installed. Because there is no easy way around this x x problem, you should be sure to check that the xserver-xorg package is installed x x after upgrade. If it is not installed and you require it, it is recommended that x x you install the xorg package to make sure you have a fully functional X setup. x x x x <Ok> x x x mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
そのままエンターキーで次に進みます。
Selecting previously deselected package x11-common. (Reading database ... 17557 files and directories currently installed.) Unpacking x11-common (from .../x11-common_1%3a7.1.0-19_powerpc.deb) ... Selecting previously deselected package libxau6. Unpacking libxau6 (from .../libxau6_1%3a1.0.1-2_powerpc.deb) ... Selecting previously deselected package libxdmcp6. Unpacking libxdmcp6 (from .../libxdmcp6_1%3a1.0.1-2_powerpc.deb) ... Setting up x11-common (7.1.0-19) ... Setting up X server socket directory /tmp/.X11-unix.... Setting up ICE socket directory /tmp/.ICE-unix.... Selecting previously deselected package libx11-data. (Reading database ... 17602 files and directories currently installed.) Unpacking libx11-data (from .../libx11-data_2%3a1.0.3-7_all.deb) ... Selecting previously deselected package libx11-6. Unpacking libx11-6 (from .../libx11-6_2%3a1.0.3-7_powerpc.deb) ... Selecting previously deselected package libdbus-1-3. Unpacking libdbus-1-3 (from .../libdbus-1-3_1.0.2-1+etch2_powerpc.deb) ... Selecting previously deselected package dbus. Unpacking dbus (from .../dbus_1.0.2-1+etch2_powerpc.deb) ... Selecting previously deselected package dnsmasq. Unpacking dnsmasq (from .../dnsmasq_2.35-1+etch4_powerpc.deb) ... Setting up libxau6 (1.0.1-2) ... Setting up libxdmcp6 (1.0.1-2) ... Setting up libx11-data (1.0.3-7) ... Setting up libx11-6 (1.0.3-7) ... Setting up libdbus-1-3 (1.0.2-1+etch2) ... Setting up dbus (1.0.2-1+etch2) ... Adding group `messagebus' (GID 105) ... Done. Adding system user `messagebus' (UID 101) ... Adding new user `messagebus' (UID 101) with group `messagebus' ... Not creating home directory `/var/run/dbus'. Starting system message bus: dbus. Setting up dnsmasq (2.35-1+etch4) ... Starting DNS forwarder and DHCP server: dnsmasq. KAGUYA:~#
DNSの動作確認用にdigコマンドとnslookupコマンドとを導入します。
digコマンドとnslookupはdnsutilsパッケージに含まれます。
KAGUYA:~# aptitude install dnsutils[ENTER]
dnsutils導入画面(例)
Reading package lists... Done Building dependency tree... Done Reading extended state information Initializing package states... Done Reading task descriptions... Done Building tag database... Done The following NEW packages will be automatically installed: bind9-host libbind9-0 libdns22 libisc11 libisccc0 libisccfg1 liblwres9 The following NEW packages will be installed: bind9-host dnsutils libbind9-0 libdns22 libisc11 libisccc0 libisccfg1 liblwres9 0 packages upgraded, 8 newly installed, 0 to remove and 0 not upgraded. Need to get 1373kB of archives. After unpacking 3609kB will be used. Do you want to continue? [Y/n/?]
Y[ENTER]
Writing extended state information... Done Get:1 http://security.debian.org etch/updates/main libisc11 1:9.3.4-2etch4 [174kB] Get:2 http://security.debian.org etch/updates/main libdns22 1:9.3.4-2etch4 [488kB] Get:3 http://security.debian.org etch/updates/main libisccc0 1:9.3.4-2etch4 [96.2kB] Get:4 http://security.debian.org etch/updates/main libisccfg1 1:9.3.4-2etch4 [109kB] Get:5 http://security.debian.org etch/updates/main libbind9-0 1:9.3.4-2etch4 [96.2kB] Get:6 http://security.debian.org etch/updates/main liblwres9 1:9.3.4-2etch4 [112kB] Get:7 http://security.debian.org etch/updates/main bind9-host 1:9.3.4-2etch4 [114kB] Get:8 http://security.debian.org etch/updates/main dnsutils 1:9.3.4-2etch4 [183kB] Fetched 1373kB in 11s (120kB/s) Selecting previously deselected package libisc11. (Reading database ... 17915 files and directories currently installed.) Unpacking libisc11 (from .../libisc11_1%3a9.3.4-2etch4_powerpc.deb) ... Selecting previously deselected package libdns22. Unpacking libdns22 (from .../libdns22_1%3a9.3.4-2etch4_powerpc.deb) ... Selecting previously deselected package libisccc0. Unpacking libisccc0 (from .../libisccc0_1%3a9.3.4-2etch4_powerpc.deb) ... Selecting previously deselected package libisccfg1. Unpacking libisccfg1 (from .../libisccfg1_1%3a9.3.4-2etch4_powerpc.deb) ... Selecting previously deselected package libbind9-0. Unpacking libbind9-0 (from .../libbind9-0_1%3a9.3.4-2etch4_powerpc.deb) ... Selecting previously deselected package liblwres9. Unpacking liblwres9 (from .../liblwres9_1%3a9.3.4-2etch4_powerpc.deb) ... Selecting previously deselected package bind9-host. Unpacking bind9-host (from .../bind9-host_1%3a9.3.4-2etch4_powerpc.deb) ... Selecting previously deselected package dnsutils. Unpacking dnsutils (from .../dnsutils_1%3a9.3.4-2etch4_powerpc.deb) ... Setting up libisc11 (9.3.4-2etch4) ... Setting up libdns22 (9.3.4-2etch4) ... Setting up libisccc0 (9.3.4-2etch4) ... Setting up libisccfg1 (9.3.4-2etch4) ... Setting up libbind9-0 (9.3.4-2etch4) ... Setting up liblwres9 (9.3.4-2etch4) ... Setting up bind9-host (9.3.4-2etch4) ... Setting up dnsutils (9.3.4-2etch4) ... KAGUYA:~#
/etc/hostsにpman10.dyndns.orgを追加します。
KAGUYA:~# vi /etc/hosts[ENTER]
/etc/hostsの例
127.0.0.1 localhost # 192.168.0.100 KURO-BOX
以下の行にpman10.dyndns.orgを追加
旧
192.168.100.100 KAGUYA
新
192.168.100.100 pman10.dyndns.org KAGUYA
# The following lines are desirable for IPv6 capable hosts # (added automatically by netbase upgrade) ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts
dnsmasqの設定ですが傾向として2パターンあるようです。
DebianではなくUbuntsu用かもしれませんが…。
とりあえずパターン2で動作しています。
resolv.conf自動生成時にlocalhostが挿入されるように設定します。
KAGUYA:~# vi /etc/dhclient.conf[ENTER]
/etc/dhclient.confの例
: (省略)
以下の1行の#を削除してコメントをはずす
旧
#prepend domain-name-servers 127.0.0.1;
新
prepend domain-name-servers 127.0.0.1;
: (省略)
設定を有効にするために面倒なので玄箱/HGをリブートします。
生成されたresolv.confは以下のようになっているはずです。
KAGUYA:~# cat /etc/dnsmasq.conf[ENTER]
/etc/resolv.confの例
nameserver 127.0.0.1 nameserver 192.168.100.1
現状のresolv.confをresolv.conf.dnsmasqとしてコピーして、resolv.confはlocalhostになるように編集します。
KAGUYA:~# cp -p /etc/resolv.conf /etc/dnsmasq.conf.dnsmasq[ENTER]
KAGUYA:~# vi /etc/resolv.conf[ENTER]
/etc/resolv.confの例
nameserver 127.0.0.1
KAGUYA:~# cat /etc/dnsmasq.conf.dnsmasq[ENTER]
/etc/resolv.conf.dnsmasqの例
nameserver 192.168.24.1
dnsmasq.confでコピーしたresolv.conf.dnsmasqを使うように設定します。
KAGUYA:~# vi /etc/dnsmasq.conf[ENTER]
/etc/dnsmasq.confの例
: (省略)
以下の1行の#を削除してコメントをはずして修正
旧
#resolv-file=
新
resolv-file=/etc/resolv.conf.dnsmasq
: (省略)
以下の1行の#を削除してコメントをはずす
旧
#local=/localnet/
新
local=/localnet/
: (省略)
設定を有効にするために面倒なので玄箱/HGをリブートします。
一応、管理者権限(管理者アカウント参照)で作業します。
nslookupコマンドで確認します。
以下のように名前からWANではなくLAN上のIPアドレスが表示できればOKです。
KAGUYA:~# nslookup pman10.dyndns.org[ENTER]
nslookupの出力の例
Server: 192.168.100.1 Address: 192.168.100.1#53 Name: pman10.dyndns.org Address: 192.168.100.100 KAGUYA:~#
digコマンドでも確認します。
以下のように名前からWANではなくLAN上のIPアドレスが表示できればOKです。
KAGUYA:~# dig @localhost pman10.dyndns.org[ENTER]
digの出力の例
; <<>> DiG 9.3.4-P1.1 <<>> @localhost pman10.dyndns.org ; (1 server found) ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23503 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;pman10.dyndns.org. IN A ;; ANSWER SECTION: pman10.dyndns.org. 0 IN A 192.168.100.100 ;; Query time: 8 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Thu May 21 23:49:11 2009 ;; MSG SIZE rcvd: 51 KAGUYA:~#
PCのDOSプロンプトからnslookupコマンドで確認します。
以下のように名前からWANではなくLAN上のIPアドレスが表示できればOKです。
C:\>nslookup pman10.dyndns.org[ENTER]
nslookupの出力の例
DNS request timed out. timeout was 2 seconds. サーバー: UnKnown Address: 192.168.100.1 DNS request timed out. timeout was 2 seconds. 名前: pman10.dyndns.org Address: 192.168.100.100 C:\>
PCのDOSプロンプトからtracertコマンドでも確認します。
以下のように名前からWANではなくLAN上のIPアドレスが表示できればOKです。
C:\>tracert pman10.dyndns.org[ENTER]
tracert出力(例)
pman10.dyndns.org [192.168.100.100] へのルートをトレースしています 経由するホップ数は最大 30 です: 1 2 ms 2 ms 2 ms KAGUYA [192.168.100.100] トレースを完了しました。 C:\>
ブラウザで
http://pman10.dyndns.org/
のように玄箱/HGを表示します。
pman10.dyndns.orgで接続できることを確認しました。
光プレミアム導入に伴いCTU設定により本設定は不要になりました。
管理者権限(管理者アカウント参照)で削除しておきます。
aptitude remove dnsmasq[ENTER]
/etc/hostsに追加した行も削除しておきましょう。
光プレミアム導入でCTU設定するのはDNSのアドレスだったのでにより本設定は必要になりました。
コメントはありません。 コメント/玄箱HGメモ/Debian/DNSキャッシュサーバ導入?
Online: 1