LS-GL: debian: DNS


ネームサーバをセットアップする

インストールするパッケージ

最初、apt-cache で "named" を探していたのだが、 全然見つからなかった(汗)
"bind" を探すと一発で見つかった。
yasunari@ude:~$ apt-cache --names-only search bind
	:
	:
bind - Internet Domain Name Server
bind-dev - libraries used by BIND
bind-doc - documentation for BIND
bind9 - Internet Domain Name Server
bind9-doc - Documentation for BIND
bind9-host - Version of 'host' bundled with BIND 9.X
	:
	:
yasunari@ude:~$
bind9 をインストールすると良いみたい。

bind のインストール

bind9 をインストールする
ude:~# apt-get install bind9
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
  libdns16 libisc7 libisccc0 libisccfg0 liblwres1
Suggested packages:
  dnsutils bind9-doc
The following NEW packages will be installed:
  bind9 libdns16 libisc7 libisccc0 libisccfg0 liblwres1
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 1150kB of archives.
After unpacking 2626kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ftp.jp.debian.org sarge/main libisc7 1:9.2.4-1sarge1 [157kB]
Get:2 http://ftp.jp.debian.org sarge/main libdns16 1:9.2.4-1sarge1 [462kB]
Get:3 http://ftp.jp.debian.org sarge/main liblwres1 1:9.2.4-1sarge1 [90.3kB]
Get:4 http://ftp.jp.debian.org sarge/main libisccc0 1:9.2.4-1sarge1 [75.6kB]
Get:5 http://ftp.jp.debian.org sarge/main libisccfg0 1:9.2.4-1sarge1 [88.1kB]
Get:6 http://ftp.jp.debian.org sarge/main bind9 1:9.2.4-1sarge1 [277kB]
Fetched 1150kB in 7s (150kB/s)
Selecting previously deselected package libisc7.
(Reading database ... 11029 files and directories currently installed.)
Unpacking libisc7 (from .../libisc7_1%3a9.2.4-1sarge1_arm.deb) ...
Selecting previously deselected package libdns16.
Unpacking libdns16 (from .../libdns16_1%3a9.2.4-1sarge1_arm.deb) ...
Selecting previously deselected package liblwres1.
Unpacking liblwres1 (from .../liblwres1_1%3a9.2.4-1sarge1_arm.deb) ...
Selecting previously deselected package libisccc0.
Unpacking libisccc0 (from .../libisccc0_1%3a9.2.4-1sarge1_arm.deb) ...
Selecting previously deselected package libisccfg0.
Unpacking libisccfg0 (from .../libisccfg0_1%3a9.2.4-1sarge1_arm.deb) ...
Selecting previously deselected package bind9.
Unpacking bind9 (from .../bind9_1%3a9.2.4-1sarge1_arm.deb) ...
Setting up libisc7 (9.2.4-1sarge1) ...

Setting up libdns16 (9.2.4-1sarge1) ...

Setting up liblwres1 (9.2.4-1sarge1) ...

Setting up libisccc0 (9.2.4-1sarge1) ...

Setting up libisccfg0 (9.2.4-1sarge1) ...

Setting up bind9 (9.2.4-1sarge1) ...
Adding group `bind' (104)...
Done.
Adding system user `bind'...
Adding new user `bind' (100) with group `bind'.
Not creating home directory.
Starting domain name service: named.

ude:~#

設定ファイル?

ude:~# ls /etc/named*
ls: /etc/named*: No such file or directory
ude:~# ls /var/named*
ls: /var/named*: No such file or directory
ude:~#
設定ファイルが全然ないのに起動したの? と思って、/var/log/daemon.log を見てみると、、、
Jan 20 09:50:48 ude named[715]: starting BIND 9.2.4 -u bind
Jan 20 09:50:48 ude named[715]: using 1 CPU
Jan 20 09:50:48 ude named[717]: loading configuration from '/etc/bind/named.conf'
Jan 20 09:50:48 ude named[717]: no IPv6 interfaces found
Jan 20 09:50:48 ude named[717]: listening on IPv4 interface eth0, 192.168.1.38#53
Jan 20 09:50:48 ude named[717]: listening on IPv4 interface lo, 127.0.0.1#53
Jan 20 09:50:48 ude named[717]: command channel listening on 127.0.0.1#953
Jan 20 09:50:48 ude named[717]: zone 0.in-addr.arpa/IN: loaded serial 1
Jan 20 09:50:48 ude named[717]: zone 127.in-addr.arpa/IN: loaded serial 1
Jan 20 09:50:48 ude named[717]: zone 255.in-addr.arpa/IN: loaded serial 1
Jan 20 09:50:48 ude named[717]: zone localhost/IN: loaded serial 1
Jan 20 09:50:48 ude named[717]: running
設定ファイルは、/etc/bind にあるようだ。

/etc/bind を散歩してみた。

bind の設定

zone を追加するには、/etc/bind/named.conf.local に記述するようだ。

内向き DNS として yamasita.jp と 192.168.1 を追加する

/etc/bind/named.conf.local

ude:/etc/bind# mv named.conf.local named.conf.local.orig
ude:/etc/bind# cp named.conf.local.orig named.conf.local
ude:/etc/bind# ls -l named.conf.local*
-rw-r--r--  1 root bind 165 Jan 20 10:09 named.conf.local
-rw-r--r--  1 root bind 165 Sep  8 00:22 named.conf.local.orig
ude:/etc/bind# vi named.conf.local
	:
	:
ude:/etc/bind# diff named.conf.local.orig named.conf.local
8a9,17
> zone "yamasita.jp" {
>       type master;
>       file "/etc/bind/yamasita.jp-in-zone";
> };
>
> zone "1.168.192.in-addr.arpa" {
>       type master;
>       file "/etc/bind/1.168.192-rev";
> };
ude:/etc/bind#
ネーミングコンベンションがぐちゃぐちゃだが、 これまで Vine で使用していたファイル名に合わせた。

/etc/bind/yamasita.jp-in-zone

$TTL 3600       ; 1 hour
yamasita.jp.            IN SOA  ns.yamasita.jp. root.yamasita.jp. (
                                2006121502 ; serial
                                3600       ; refresh (1 hour)
                                300        ; retry (5 minutes)
                                3600000    ; expire (5 weeks 6 days 16 hours)
                                3600       ; minimum (1 hour)
                                )
                        NS      ns.yamasita.jp.
                        NS      link.yamasita.jp.
                        A       192.168.1.2
                        MX      1 ns.yamasita.jp.
broad                   A       192.168.1.1
ns                      A       192.168.1.2
ftp                     CNAME   ns
mail                    CNAME   ns
pop                     CNAME   ns
smtp                    CNAME   ns
www                     CNAME   ns
hb                      A       192.168.1.5
hackkit                 A       192.168.1.6
broad2                  A       192.168.1.7
air                     A       192.168.1.9
	:
	:

/etc/bind/1.168.192-rev

$TTL 3600       ; 1 hour
1.168.192.in-addr.arpa. IN SOA  ns.yamasita.jp. root.yamasita.jp. (
                                2007012001 ; serial
                                3600       ; refresh (1 hour)
                                300        ; retry (5 minutes)
                                3600000    ; expire (5 weeks 6 days 16 hours)
                                3600       ; minimum (1 hour)
                                )
                        NS      ns.yamasita.jp.
                        NS      link.yamasita.jp.
1                       PTR     broad.yamasita.jp.
2                       PTR     ns.yamasita.jp.
5                       PTR     hb.yamasita.jp.
6                       PTR     hackkit.yamasita.jp.
7                       PTR     broad2.yamasita.jp.
9                       PTR     air.yamasita.jp.
	:
	:

named の再起動

ude:/etc/bind# /etc/init.d/bind9 stop
Stopping domain name service: named.
ude:/etc/bind# /etc/init.d/bind9 start
Starting domain name service: named.
ude:/etc/bind# cat /var/log/daemon.log
	:
	:
Jan 20 10:31:56 ude named[856]: starting BIND 9.2.4 -u bind
Jan 20 10:31:56 ude named[856]: using 1 CPU
Jan 20 10:31:56 ude named[858]: loading configuration from '/etc/bind/named.conf'
Jan 20 10:31:56 ude named[858]: no IPv6 interfaces found
Jan 20 10:31:56 ude named[858]: listening on IPv4 interface eth0, 192.168.1.38#53
Jan 20 10:31:56 ude named[858]: listening on IPv4 interface lo, 127.0.0.1#53
Jan 20 10:31:56 ude named[858]: command channel listening on 127.0.0.1#953
Jan 20 10:31:56 ude named[858]: zone 0.in-addr.arpa/IN: loaded serial 1
Jan 20 10:31:56 ude named[858]: zone 127.in-addr.arpa/IN: loaded serial 1
Jan 20 10:31:56 ude named[858]: zone 1.168.192.in-addr.arpa/IN: loaded serial 2007012001
Jan 20 10:31:56 ude named[858]: zone 255.in-addr.arpa/IN: loaded serial 1
Jan 20 10:31:56 ude named[858]: zone yamasita.jp/IN: loaded serial 2006121502
Jan 20 10:31:56 ude named[858]: zone localhost/IN: loaded serial 1
Jan 20 10:31:56 ude named[858]: running
Jan 20 10:31:56 ude named[858]: zone 1.168.192.in-addr.arpa/IN: sending notifies (serial 2007012001)
Jan 20 10:31:56 ude named[858]: zone yamasita.jp/IN: sending notifies (serial 2006121502)

動作確認

ude:/etc/bind# nslookup
-su: nslookup: command not found
debian には nslookup がなかった。host コマンドを使うとのこと。

手を抜いて Vine の nslookup を使って確認する。

[yasunari@ns yasunari]$ nslookup
> server ude
Default server: ude
Address: 192.168.1.38#53
> ns
Server:         ude
Address:        192.168.1.38#53

Name:   ns.yamasita.jp
Address: 192.168.1.2
> 192.168.1.2
Server:         ude
Address:        192.168.1.38#53

2.1.168.192.in-addr.arpa        name = ns.yamasita.jp.
> set q=mx
> yamasita.jp.
Server:         ude
Address:        192.168.1.38#53

yamasita.jp     mail exchanger = 1 ns.yamasita.jp.
>
[yasunari@ns yasunari]$
いけてるかな。

ただ、view を使うにはひと工夫要りそう。




LS-GL: debian: デフォルトエディタ
ハックの記録
LinkStation/玄箱 をハックしよう

IP alias

Copyright (C) 2007 Yasunari Yamashita. All Rights Reserved.
yasunari @ yamasita.jp 山下康成@京都府向日市