This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.
Please visit our production wiki at https://wiki.gentoo.org
BIND/ガイド
This guide teaches the reader how install and configure BIND for a domain and a local network.
はじめに
This tutorial will show you how to install and configure BIND, the most used DNS server on Internet. We will configure BIND for a domain using different configurations, one for a local network and one for the rest of the world. Two views will be used to do so:
- View of the internal zone (your local network).
- View for the external zone (rest of the world).
この例で使用しているデータ
キーワード | 説明 | 例 |
---|---|---|
YOUR_DOMAIN | あなたのドメイン名 | gentoo.org |
YOUR_PUBLIC_IP | ISPから提供されているグローバルIPアドレス | 204.74.99.100 |
YOUR_LOCAL_IP | ローカルのIPアドレス | 192.168.1.5 |
YOUR_LOCAL_NETWORK | ローカルのネットワーク | 192.168.1.0/24 |
SLAVE_DNS_SERVER | あなたのドメインで利用しているスレーブDNSサーバのIPアドレス | 209.177.148.228 |
ADMIN | DNSサーバの管理者のユーザ名 | root |
MODIFICATION | ゾーンファイルの更新日に連番を加えたもの | 2009062901 |
BIND の設定
インストール
まず、 net-dns/bind をインストールしましょう。
root #
emerge --ask net-dns/bind
/etc/bind/named.conf の設定
最初に、/etc/bind/named.conf を設定します。このステップでの1番目の作業は、bind のルートディレクトリ、及び、各IPアドレスで開くポート、 pid ファイル、IPv6 プロトコルに関する行を設定です。
'"`UNIQ--pre-00000001-QINU`"'
This is a deprecated template. Help us update this template!
named.conf に関する2番目の作業は、ローカルネットワークに対する内部ビューです。
'"`UNIQ--pre-00000004-QINU`"'
This is a deprecated template. Help us update this template!
named.conf に関する3番目の作業は、あなたのドメイン名が全世界でも引け、他のドメイン名をあなた(及びあなたのDNSサーバを利用する誰も)が引けるようにするための外部ビューです。
'"`UNIQ--pre-00000007-QINU`"'
This is a deprecated template. Help us update this template!
named.conf に関する最後の作業は、ロギングポリシーの設定です。
'"`UNIQ--pre-0000000A-QINU`"'
This is a deprecated template. Help us update this template!
/var/log/named/ ディレクトリが存在し、その所有権が named
にある必要があります。
root #
mkdir -p /var/log/named/
root #
chmod 770 /var/log/named/
root #
touch /var/log/named/named.log
root #
chmod 660 /var/log/named/named.log
root #
chown -R named /var/log/named/
root #
chgrp -R named /var/log/named/
内部ゾーンファイルの作成
上記ネットワーク例のホスト名とIPアドレスを使用すると以下のとおりです。(すべてではないものの)ほとんどのドメイン名は「.」(ドット)で終わっていますので、気をつけてください。
'"`UNIQ--pre-0000000D-QINU`"'
This is a deprecated template. Help us update this template!
外部ゾーンファイルの作成
あとは、外部クライアント(wwwやmail、ns)のためのサブドメインの設定だけが残っています。
'"`UNIQ--pre-00000010-QINU`"'
This is a deprecated template. Help us update this template!
設定を完了する
named
を default ランレベルに追加しましょう:
root #
rc-update add named default
クライアント側の設定
これで、あなた用のDNSサーバを利用して、あなたのローカルネットワーク上のすべてのマシンでドメイン名が引けるようになります。あなたのローカルネットワーク上のすべてのマシンで、/etc/resolv.conf ファイルを書換えましょう。
'"`UNIQ--pre-00000013-QINU`"'
This is a deprecated template. Help us update this template!
YOUR_DNS_SERVER_IP は、この文書にある YOUR_LOCAL_IP と同じです。今回の例そのままだと 192.168.1.5 にあたります。
テスト
これで、新しい DNS サーバの動作テストができる段階になりました。まずは、サービスを起動しなければなりません。
root #
/etc/init.d/named start
つぎに、いくつかのドメインについて、host コマンドを試してみましょう。このテストは、ローカルネットワーク上のどのマシンでも実行することができます。もし、 net-dns/host
をインストールしていないようなら、その代わりに ping
コマンドが利用可能ですし、もういっそのこと emerge host
してもよいでしょう。
user $
host www.gentoo.org
www.gentoo.org has address 209.177.148.228 www.gentoo.org has address 209.177.148.229
user $
host hell
hell.YOUR_DOMAIN has address 192.168.1.3
user $
host router
router.YOUR_DOMAIN has address 192.168.1.1
iptables によるサーバ防御
サーバの防御のために iptables を利用するならば、 iptables のルールに DNS サービスについても追加しましょう。
'"`UNIQ--pre-00000019-QINU`"'
This is a deprecated template. Help us update this template!
This page is based on a document formerly found on our main website gentoo.org.
The following people contributed to the original document: Vicente Olivert Riera, nightmorph
They are listed here because wiki history does not allow for any external attribution. If you edit the wiki article, please do not add yourself here; your contributions are recorded on each article's associated history page.