ホーム > ohwada

ohwada

記事一覧 > はっぴぃ・りなっくす > bind 9 CentOS 5

bind 9 CentOS 5

機能

DNS (Domain Name System) サーバー

インストール


# yum install bind bind-chroot
# yum install caching-nameserver 


設定

named.conf がないので、自分で作る

# cd /var/named/chroot/etc/
# cp -p named.caching-nameserver.conf named.conf


/var/named/chroot/etc/named.conf

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";

// 外部からの問合せを許可する
	allow-query     { any; };

	allow-query-cache { localhost; };

// スレーブへのゾーン転送を許可する
	allow-transfer {
		xxx.xxx.xxx.xxx;
	};
};

// rndc key を指定する
controls {
	inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};

include "/etc/rndc.key";

logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};

// view 指定を外す
//view localhost_resolver {
//	match-clients 	   { localhost; };
//	match-destinations { localhost; };
//	recursion yes;
//	include "/etc/named.rfc1912.zones";
//};
include "/etc/named.rfc1912.zones";

// マスターのソーンファイルを指定する
include "/etc/named.master.zones";


/var/named/chroot/etc/named.master.zones

zone "exsample.com"{
	type master;
	file "masters/exsample.com.zone";
	allow-update { none; };
};


/var/named/chroot//var/named/masters/exsample.com.zone

$TTL	86400
@		IN	SOA	host.exsample.com.	postmaster.exsample.com. (
			2010010101 ; serial
			86400 ; refresh
			3600 ; retry
			3600000 ; expire
			1200 ; Negative Cache TTL
			)
@		IN	A	xxx.xxx.xxx.xxx
@		IN	NS	ns1.exsample.com.
@		IN	NS	ns4.exsample.com.
@		IN	MX	10	mail.exsample.com.
localhost		IN	A	127.0.0.1
host		IN	A	xxx.xxx.xxx.xxx
ns1		IN	A	xxx.xxx.xxx.xxx
ns2		IN	A	xxx.xxx.xxx.xxx
mail		IN	A	xxx.xxx.xxx.xxx


named に 書込み権限を与える

# chmod g+w /var/named/chroot/var/named


デーモン起動

# /etc/init.d/named start


確認

下記のように設定した値が表示できたら、OK

# dig exsample.com @localhost

; <<>> DiG 9.3.6-P1-RedHat-9.3.6-4.P1.el5_4.2 <<>> exsample.com @localhost
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2075
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 3

;; QUESTION SECTION:
;exsample.com.                     IN      A

;; ANSWER SECTION:
exsample.com.              86400   IN      A       xxx.xxx.xxx.xxx

;; AUTHORITY SECTION:
exsample.com.              86400   IN      NS      ns1.exsample.com.
exsample.com.              86400   IN      NS      ns2.exsample.com.

;; ADDITIONAL SECTION:
ns1.exsample.com.          86400   IN      A       xxx.xxx.xxx.xxx
ns2.exsample.com.          86400   IN      A       xxx.xxx.xxx.xxx
host.exsample.com.         86400   IN      A       xxx.xxx.xxx.xxx

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Sun Mar  7 00:44:17 2010
;; MSG SIZE  rcvd: 147


参考

- 「BIND」の設定


To Top