发新话题
 搜藏 打印 该页面添加到 Mister Wong

BIND 9.3.2 + DLZ with MYSQL 安装文档

BIND 9.3.2 + DLZ with MYSQL 安装文档

作者:microsea
BIND 9.3.2 + DLZ with MYSQL 安装文档 by microsea
ICP提供DNS服务,肯定需要用到将DNS数据入库管理,并且能动态更改的需求.在尝试网上流传的<<bind-9.3.1 + mysql-4.1.9 + web管理详细配置全过程>>一文发现一个问题:

每增加一个域就要修改named.conf文件加入
复制内容到剪贴板
代码:
zone "mydomain.com" { type master; database "mysqldb dnsdb mydomain localhost root passwd"; };
修改后仍需重启named,没有实现真正的动态添加修改DNS的目的.

采用BIND+DLZ则做到了Dynamically Loadable Zones.

所谓DLZ (Dynamically Loadable Zones) is a patch for BIND version 9 that simplifies BIND
administration and reduces memory usage and startup time. DLZ allows you to store your zone
data in a database. Unlike using scripts, the changes in your database are immediately
reflected in BIND's response to DNS queries, so there is no need to reload or restart BIND.
You see, BIND "dynamically loads" the "zone" data it needs to answer a query from the
database.
下面是安装步骤:
less..
1.下载BIND 9.3.2 源码包:

http://www.isc.org/sw/dl/?pkg=bind9/9.3.2/bind-9.3.2.tar.gz&name=BIND 9.3.2

2.下载DLZ非官方(unofficial)补丁:

http://projects.navynet.it/DLZ/ctrix_dlz_9.3.2-1.patch.gz

3.安装

将补丁和BIND包上传至同一目录

tar xvzf bind-9.3.2.tar.gz

mv ctrix_dlz_9.3.2-1.patch.gz bind-9.3.2/ctrix_dlz_9.3.2-1.patch

patch -p1 < ctrix_dlz_9.3.2-1.patch

./configure --with-dlz-mysql --enable-threads=no --prefix=/usr/local/bind-dlz

make

make install

4.配置

cd /usr/local/bind-dlz

mkdir etc

mkdir var/run -p

chown named.named var -R

创建named.conf文件,我的named.conf如下:
复制内容到剪贴板
代码:
options {        version "microsea-ICP";        recursion no; };
controls {        inet 127.0.0.1 allow { localhost; } keys { rndckey; }; }; dlz "Mysql zone" {   database "mysql   {host=localhost dbname=dns_data ssl=tRue}   {select zone from dns_records where zone = '%zone%'}   {select ttl, type, mx_priority, case when lower(type)='txt' then concat('\"', data, '\"')        when lower(type) = 'soa' then concat_ws(' ', data, resp_person, serial, refresh, retry, expire, minimum)        else data end from dns_records where zone = '%zone%' and host = '%record%'}";};
include "/usr/local/bind-932/etc/rndc.key";
注: {host=localhost dbname=dns_data user=root pass=root}为mysql的链接串.



5.创建mysql中相关数据库和表,以及创建索引,具体指令略:

参见:  http://bind-dlz.sourceforge.net/mysql_example.html



在数据库中插入测试记录:
复制内容到剪贴板
代码:
mysql> INSERT INTO `dns_records` ( `zone` , `host` , `type` , `data` , `ttl` , `mx_priority`
, `refresh` , `retry` , `expire` , `minimum` , `serial` , `resp_person` , `primary_ns` ) VALUES ( 'givingtree.com.cn', 'ilovefiona', 'A', '222.222.222.22', '800', NULL , NULL , '10', NULL ,
NULL , NULL , NULL , NULL );
5.测试

启动服务器:

/usr/local/bind-dlz/sbin/named -u named -g -d1

新开一个登录窗口测试
复制内容到剪贴板
代码:
nslookup > server localhost Default server: localhost Address: 127.0.0.1#53 > ilovefiona.givingtree.com.cn Server:         localhost Address:        127.0.0.1#53
Name:   ilovefiona.givingtree.com.cn Address: 222.222.222.22 > exit
服务器返回信息:
复制内容到剪贴板
代码:
05-Apr-2006 11:27:00.747 Query String: select zone from dns_records where zone = 'ilovefiona.givingtree.com.cn'
05-Apr-2006 11:27:00.747 Query String: select zone from dns_records where zone = 'givingtree.com.cn'
05-Apr-2006 11:27:00.748 Query String: update data_count set count = count + 1 where zone ='givingtree.com.cn'
05-Apr-2006 11:27:00.748 Query String: select ttl, type, mx_priority, case when lower(type)='txt' then concat('"',
data, '"')        else data end from dns_records where zone = 'givingtree.com.cn' and host =
'ilovefiona'        and not (type = 'SOA' or type = 'NS')
05-Apr-2006 11:27:00.749 Query String: select ttl, type, mx_priority, case when lower(type)='txt' then concat('"',
data, '"')        else data end from dns_records where zone = 'givingtree.com.cn' and host = '@'        and not (type = 'SOA' or type = 'NS')
05-Apr-2006 11:27:00.749 Query String: select ttl, type, mx_priority, case when lower(type)='txt' then concat('"',
data, '"')        else data end from dns_records where zone = 'givingtree.com.cn' and host = '*'        and not (type = 'SOA' or type = 'NS')
05-Apr-2006 11:27:00.749 Query String: select ttl, type, mx_priority, data, resp_person, serial, refresh, retry,
expire, minimum        from dns_records where zone = 'givingtree.com.cn' and (type = 'SOA' or type='NS')
注: named.conf中其他内容可参考/etc/named.conf添加,如:
复制内容到剪贴板
代码:
zone "." IN {        type hint;        file "named.ca"; };
zone "localdomain" IN {        type master;        file "localdomain.zone";        allow-update { none; }; };
zone "localhost" IN {        type master;        file "localhost.zone";        allow-update { none; }; };
这些固定不变,不需要读库的内容可预先设好,要将named.ca的内容入库也是可以的.
参考文献:

<<Bind DLZ Extended Tags> :  http://team.lea-linux.org/prae/dlz/

Unofficial patchs for bind 9.3.1* :  http://projects.navynet.it/

BIND DLZ Home: http://bind-dlz.sourceforge.net/


http://www.givingtree.com.cn/36

本文由hew 发布于Linuxsky 论坛,网址:http://bbs.linuxsky.org/thread-6556-1-1.html

相关主题
你的鼓励,我的动力.
做人厚道,看贴回贴.
my linux blog

TOP

发新话题