WEBの勉強ノート
Loading

BIND インストールと設定

2010 年 2 月 28 日 カテゴリー: BIND

テストサーバーを構築した時のメモ。CentOS5.4 。公開サーバーではないので、外部向けの設定は行っていません。

インストール

[root@centos ~]# yum -y install bind bind-chroot caching-nameserver

BIND設定ファイル所有グループ変更。

[root@centos ~]# chgrp named /var/named/chroot/etc/named.conf

色を付けた所を追加。

[root@localhost ~]# vi /var/named/chroot/etc/named.conf
//
// named.caching-nameserver.conf
//
// Provided by Red Hat caching-nameserver package to configure the
// ISC BIND named(8) DNS server as a caching only nameserver
// (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
// DO NOT EDIT THIS FILE - use system-config-bind or an editor
// to create named.conf - edits to this file will be lost on
// caching-nameserver package upgrade.
//
options {
        # listen-on port 53 { 127.0.0.1; };
        # listen-on-v6 port 53 { ::1; };
        directory       "/var/named";
        dump-file       "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";

        // Those options should be used carefully because they disable port
        // randomization
        // query-source    port 53;
        // query-source-v6 port 53;

        allow-query     { localhost; localnets; };
        allow-query-cache { localhost; localnets; };

        forwarders{
                192.168.0.1;
        };
};
logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};
view localhost_resolver {
        match-clients      { localhost; };
        match-destinations { localhost; };
        recursion yes;
        include "/etc/named.rfc1912.zones";
        include "/etc/named.localhost.com.zone";
};
view "internal" {
        match-clients { localnets; };
        match-destinations { localnets; };
        recursion yes;
        include "/etc/named.rfc1912.zones";
        include "/etc/named.localhost.com.zone";
};

ゾーンファイル作成。

[root@localhost ~]# vi /var/named/chroot/etc/named.localhost.com.zone
zone "localhost.com" {
        type master;
        file "localhost.com.db";
};
zone "0.168.192.in-addr.arpa" {
        type master;
        file "0.168.192.in-addr.arpa.db";
};

内部向け正引き用ファイル作成。

[root@localhost ~]# vi /var/named/chroot/var/named/localhost.com.db
$TTL    86400
@       IN      SOA     localhost.com.  root.localhost.com.(
                                      2004031901 ; Serial
                                      28800      ; Refresh
                                      14400      ; Retry
                                      3600000    ; Expire
                                      86400 )    ; Minimum
        IN NS    localhost.com.
        IN MX 10 localhost.com.
@       IN A     192.168.0.250
*       IN A     192.168.0.250

内部向け逆引き用ファイル作成

[root@localhost ~]# vi /var/named/chroot/var/named/0.168.192.in-addr.arpa.db
$TTL    86400
@       IN      SOA     localhost.com.  root.localhost.com.(
                                      2004031901 ; Serial
                                      28800      ; Refresh
                                      14400      ; Retry
                                      3600000    ; Expire
                                      86400 )    ; Minimum
              IN      NS    localhost.com.
250           IN      PTR   localhost.com.

起動、自動起動設定

[root@localhost ~]# service named start
named を起動中:                                            [  OK  ]
[root@centos ~]# chkconfig named on
[root@localhost ~]# chkconfig --list named
named           0:off   1:off   2:on    3:on    4:on    5:on    6:off

nslookup などで、正引き、逆引きを確認。 複数のレコードを設定するときは、ゾーンファイルに zone{} を追加して、参照先のレコードを書いたファイルを作成。

コメントをどうぞ