CentOS サーバー構築マニュアル

home > CentOS5 > DNSサーバー BIND インストール

DNSサーバー BIND インストール




■BINDインストール
[root@ns1 ~]# yum -y install bind caching-nameserver bind-chroot
[root@ns1 ~]# yum clean packages

■named.conf編集 (非固定IPの場合)
[root@ns1 ~]# vi /var/named/chroot/etc/named.conf

↓下記を記入
//
// named.conf for Red Hat caching-nameserver
//

acl internal {
	127.0.0.1;
	192.168.3.0/24;
};


options {
	version "unknown";
	directory "/var/named";
	allow-query { internal; };
	allow-recursion { internal; };
	allow-transfer { internal; };
};

//
// a caching only nameserver config
//
controls {
	inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};

logging {
	category lame-servers { null; };
};

view "internal"{
	match-clients { internal; };
	recursion yes;

	zone "." IN {
		type hint;
		file "named.ca";
	};

	zone "0.0.127.in-addr.arpa" {
		type master;
		file "0.0.127.in-addr.arpa";
	};

	zone "3.168.192.in-addr.arpa" {
		type master;
		file "3.168.192.in-addr.arpa";
	};

	zone "centos.orz" {
		type master;
		file "centos.orz.local";
	};
};

include "/etc/rndc.key";
※黄色い部分は環境に合わせて変更してください。

■named.conf編集 (固定IPの場合)
[root@ns1 ~]# vi /var/named/chroot/etc/named.conf

↓下記を記入
//
// named.conf for Red Hat caching-nameserver
//

acl internal {
	127.0.0.1;
	192.168.3.0/24;
};


options {
	version "unknown";
	directory "/var/named";
	allow-query { internal; };
	allow-recursion { internal; };
	allow-transfer { internal; };
};

//
// a caching only nameserver config
//
controls {
	inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};

logging {
	category lame-servers { null; };
};

view "internal"{
	match-clients { internal; };
	recursion yes;

	zone "." IN {
		type hint;
		file "named.ca";
	};

	zone "0.0.127.in-addr.arpa" {
		type master;
		file "0.0.127.in-addr.arpa";
	};

	zone "3.168.192.in-addr.arpa" {
		type master;
		file "3.168.192.in-addr.arpa";
	};

	zone "centos.orz" {
		type master;
		file "centos.orz.local";
	};
};

view "external"{
	match-clients { any; };
	recursion no;

	zone "centos.orz" {
		type master;
		file "centos.orz.zone";
		allow-transfer { セカンダリDNSのIPアドレス; };
	};
};

include "/etc/rndc.key";
※黄色い部分は環境に合わせて変更してください。

ヒント ヒント

3.168.192.in-addr.arpaとは192.168.3を反対にした数字です。
IPアドレスが192.168.1.*の場合は1.168.192.in-addr.arpaになります。

セカンダリDNSがない場合は下記をコメントアウトしてください。
#allow-transfer { セカンダリDNSのIPアドレス; };

■localhost逆引き
[root@ns1 ~]# vi /var/named/chroot/var/named/0.0.127.in-addr.arpa

↓下記を記入
$TTL 86400
@	IN	SOA	ns1.centos.orz.	root.centos.orz. (
	2007052900	;Serial
	28800		;Refresh
	7200		;Retry
	604800		;Expire	
	86400		;Minimum
)

	IN	NS	ns1.centos.orz.
1	IN	PTR	localhost.
※黄色い部分は環境に合わせて変更してください。

■内部正引き
[root@ns1 ~]# vi /var/named/chroot/var/named/centos.orz.local

↓下記を記入
$TTL	86400
@	IN	SOA	ns1.centos.orz.	root.centos.orz.  (
	2007052900	;Serial
	28800		;Refresh
	7200		;Retry
	604800		;Expire
	86400		;Minimum
)
	IN	NS	ns1.centos.orz.
	IN	MX	10	mail.centos.orz.
@	IN	A	192.168.3.10
*	IN	A	192.168.3.10
mail	IN	A	192.168.3.10
※黄色い部分は環境に合わせて変更してください。

■内部逆引き
[root@ns1 ~]# vi /var/named/chroot/var/named/3.168.192.in-addr.arpa

↓下記を記入
$TTL	86400
@	IN	SOA	ns1.centos.orz.	root.centos.orz.(
	2007052900	;Serial
	28800		;Refresh
	7200		;Retry
	604800		;Expire
	86400		;Minimum
)
	IN	NS	ns1.centos.orz.
10	IN	PTR	centos.orz.
※黄色い部分は環境に合わせて変更してください。
※最終行の10はサーバーのローカルIPアドレス192.168.3.10の10です。

■外部正引き (固定IPの場合)
[root@ns1 ~]# vi /var/named/chroot/var/named/centos.orz.zone

↓下記を記入
$TTL	86400
@	IN	SOA	ns1.centos.orz.	root.centos.orz.  (
	2007052900	;Serial
	28800		;Refresh
	7200		;Retry
	604800		;Expire
	86400		;Minimum
)
	IN	NS	ns1.centos.orz.
	IN	MX	10	mail.centos.orz.
@	IN	A	xxx.xxx.xxx.xxx
*	IN	A	xxx.xxx.xxx.xxx
mail	IN	A	xxx.xxx.xxx.xxx
※黄色い部分は環境に合わせて変更してください。
※xxx.xxx.xxx.xxxは固定IPアドレス。

ヒント ヒント

TTL(Time To Live)はレコードの生存時間を設定します。
SOA(Start Of Authority)レコードにはゾーン空間についての権限などの情報を記載します。
Serial:ゾーン情報のバージョンを管理する。(慣習的に日付+更新分の2桁を付ける)
Refresh:セカンダリサーバがプライマリサーバに更新があったか確認する間隔。
Retry:上記の問い合わせで応答が得られなかった場合サイド問い合わせる間隔。
Expire:この時間を越えるとセカンダリサーバはデータを破棄する。
Minimum:キャッシュサーバが情報を保存する時間。
NSレコード:ネームサーバを記載する。
MXレコード:メールサーバを記載する。
Aレコード:ホストに対するIPアドレスを記載する。
PTRレコード:IPアドレスからホスト名(FQDN)に変換するレコード。

■ルートゾーン最新化
[root@ns1 ~]# dig . ns @128.63.2.53 > /var/named/chroot/var/named/named.ca

■BIND起動
[root@ns1 ~]# echo 'nameserver 127.0.0.1' > /etc/resolv.conf
[root@ns1 ~]# /etc/rc.d/init.d/named start
[root@ns1 ~]# chkconfig named on
[root@ns1 ~]# chkconfig --list named
named           0:off   1:off   2:on    3:on    4:on    5:on    6:off

■BIND動作確認
[root@ns1 ~]# dig @127.0.0.1 centos.orz soa ←SOAレコード確認
; <<>> DiG 9.4.2rc1 <<>> @127.0.0.1 centos.orz soa
; (1 server found)
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43511
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:
;centos.orz.                    IN      SOA

;; ANSWER SECTION:
centos.orz.             86400   IN      SOA     ns1.centos.orz. root.centos.orz.
2007052900 28800 7200 604800 86400

;; AUTHORITY SECTION:
centos.orz.             86400   IN      NS      ns1.centos.orz.

;; ADDITIONAL SECTION:
ns1.centos.orz.         86400   IN      A       192.168.3.10

;; Query time: 1 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Nov 12 09:05:30 2007
;; MSG SIZE  rcvd: 103

[root@ns1 ~]# dig @127.0.0.1 centos.orz ns ←NSレコード確認
; <<>> DiG 9.4.2rc1 <<>> @127.0.0.1 centos.orz ns
; (1 server found)
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 674
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; QUESTION SECTION:
;centos.orz.                    IN      NS

;; ANSWER SECTION:
centos.orz.             86400   IN      NS      ns1.centos.orz.

;; ADDITIONAL SECTION:
ns1.centos.orz.         86400   IN      A       192.168.3.10

;; Query time: 1 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Nov 12 09:05:41 2007
;; MSG SIZE  rcvd: 62

[root@ns1 ~]# dig @127.0.0.1 ns1.centos.orz ←Aレコード確認
; <<>> DiG 9.4.2rc1 <<>> @127.0.0.1 ns1.centos.orz
; (1 server found)
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 6634
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;ns1.centos.orz.                        IN      A

;; ANSWER SECTION:
ns1.centos.orz.         86400   IN      A       192.168.3.10

;; AUTHORITY SECTION:
centos.orz.             86400   IN      NS      ns1.centos.orz.

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Nov 12 09:06:43 2007
;; MSG SIZE  rcvd: 62

[root@ns1 ~]# dig @127.0.0.1 -x 192.168.3.10 ←逆引き確認
; <<>> DiG 9.4.2rc1 <<>> @127.0.0.1 -x 192.168.3.10
; (1 server found)
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27424
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:
;10.3.168.192.in-addr.arpa.     IN      PTR

;; ANSWER SECTION:
10.3.168.192.in-addr.arpa. 86400 IN     PTR     centos.orz.

;; AUTHORITY SECTION:
3.168.192.in-addr.arpa. 86400   IN      NS      centos.orz.

;; ADDITIONAL SECTION:
centos.orz.             86400   IN      A       192.168.3.10

;; Query time: 1 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Nov 12 09:07:01 2007
;; MSG SIZE  rcvd: 97

[root@ns1 ~]# dig @127.0.0.1 www.centos.org ←外部ホスト(キャッシュサーバー)確認
; <<>> DiG 9.4.2rc1 <<>> @127.0.0.1 www.centos.org
; (1 server found)
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51894
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 5, ADDITIONAL: 2

;; QUESTION SECTION:
;www.centos.org.                        IN      A

;; ANSWER SECTION:
www.centos.org.         120     IN      A       72.232.194.162

;; AUTHORITY SECTION:
centos.org.             13816   IN      NS      ns3.centos.org.
centos.org.             13816   IN      NS      ns2.centos.org.
centos.org.             13816   IN      NS      ns2.uklinux.net.
centos.org.             13816   IN      NS      ns.owlriver.com.
centos.org.             13816   IN      NS      ns1.centos.org.

;; ADDITIONAL SECTION:
ns2.uklinux.net.        172216  IN      A       80.84.64.25
ns.owlriver.com.        172216  IN      A       74.218.48.71

;; Query time: 284 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Nov 12 09:07:20 2007
;; MSG SIZE  rcvd: 192
※黄色い部分は環境に合わせて変更してください。

外部に公開する場合 外部に公開する場合

プロトコル(TCP/UDP)ポート53番(DNS)を開放。



Home PageTop Forum Last updated 2008-05-12

Copyright centos.server-manual.com このサイトはリンクフリーです。ご自由にリンクしてください。