一.Bind-DLZ介绍
Bind-DLZ主页: http://bind-dlz.sourceforge.net/
Bind-DLZ发布软件的频率跟不上Bind9,新版本的Bind9不被官方的Bind-DLZ支持,因此有人做了跟进。
DLZ(Dynamically Loadable Zones)与传统的BIND9不同,BIND的不足之处:
二.安装配置Bind-DLZ
#mkidr /usr/local/src/bind
#cd /usr/local/src/bind
#wget http://ftp.isc.org/isc/bind9/9.6.0-P1/bind-9.6.0-P1.tar.gz
#tar zxvf bind-9.6.0-P1.tar.gz
#cd bind-9.6.0-P1
1.编译安装 注 : 采用mysql做后台数据库,千万不能用?enable-threads选项启用多线程,网上有一些朋友使用mysql做后台,谈到bind会莫名中断服务,大部分都是因为打开了多线程。
2.创建相关配置文件 vi localhost.zone
ttl 86400 dig > named.root
3.在named.conf中添加DLZ相关的设置
#vi named.conf //在后面添加如下
dlz "Mysql zone" {
database "mysql
{ host=127.0.0.1 dbname=dns ssl=false port=3306 user=root pass= } //数据库相关连接账号,注意填写正确.
{select zone from dns_records where zone = '%zone%' limit 1}
{select ttl, type, mx_priority, case when lower(type)='txt' then concat('\"', data, '\"')
else data end from dns_records where zone = '%zone%' and host = '%record%'
and not (type = 'SOA' or type = 'NS')}
{select ttl, type, mx_priority, data, resp_person, serial, refresh, retry, expire, minimum
from dns_records where zone = '%zone%' and (type = 'SOA' or type='NS')}
{select ttl, type, host, mx_priority, data, resp_person, serial, refresh, retry, expire,
minimum from dns_records where zone = '%zone%' and not (type = 'SOA' or type = 'NS')}
{select zone from xfr_table where zone = '%zone%' and client = '%client%'}
{update data_count set count = count + 1 where zone ='%zone%'}";
};
4. 创建DNS数据库 建一个表dns_records 5.在在终端启动调试bind服务
[root@lemp ~]# /usr/local/bind/sbin/named -uroot -g -d 1
/usr/local/bind/sbin/named: error while loading shared libraries: libmysqlclient.so.16 //出错
#ln -s /usr/local/mysql/lib/mysql/libmysqlclient.so.16 /usr/lib/ //建立链链接即可.
#ldconfig
# /usr/local/bind/sbin/named -uroot -g -d 1 //无报错信息,继续如下.
三.添加相关记录并进行测试.
1.#zone anlegen:
--soa --linuxtone.org redirection for any host to linuxtone.org. --nameserver for zone --toplevel-ip-address of zone itself 2.#host anlegen:
--ip nameserver (resp_person can be NULL) A: www.linuxtone.org A:bbs.linuxtone.org 3.#host alias anlegen:
--ns2 directs to ns1 alias:man.linuxtone.org cname www alias: host.linuxton.org cname bbs 4.#mailserver anlegen:
--ns2 directs to ns1 四.相关表结构及bind查询测试.
1.表结构:
2.查询测试(增加记录实时生效,再也不要像以前一样重启相关配置文件了.)
附:
我的表结构和相关数据:{请下载}
named.conf配置文件:
四.启动脚本(增加named进程数,提高性能!)
1.创建多个named.conf配置文件
2.启动脚本
[root@lemp etc]# vi /etc/init.d/named
#!/bin/bash
# named a network name service.
# chkconfig: 345 35 75
# description: a name server
# http://www.linuxtone.org
if [ `id -u` -ne 0 ]
then
echo "ERROR:For bind to port 53,must run as root."
exit 1
fi
case "$1" in
start)
if [ -x /usr/local/bind/sbin/named ]; then
for i in `seq 1 8`
do
/usr/local/bind/sbin/named -c /usr/local/bind/etc/named1$i.conf -u root
echo "BIND9-named1$i server started"
done
fi
;;
stop)
kill `cat /usr/local/bind/var/named.pid` && echo . && echo 'BIND9 server stopped'
;;
restart)
echo .
echo "Restart BIND9 server"
$0 stop
sleep 10
$0 start
;;
reload)
/usr/local/bind/sbin/rndc reload
;;
status)
/usr/local/bind/sbin/rndc status
;;
*)
echo "$0 start | stop | restart |reload |status"
;;
Bind-DLZ主页: http://bind-dlz.sourceforge.net/
Bind-DLZ发布软件的频率跟不上Bind9,新版本的Bind9不被官方的Bind-DLZ支持,因此有人做了跟进。
DLZ(Dynamically Loadable Zones)与传统的BIND9不同,BIND的不足之处:
- BIND从文本文件中获取数据,这样容易因为编辑错误出现问题。
- BIND需要将数据加载到内存中,如果域或者记录较多,会消耗大量的内存。
- BIND启动时解析Zone文件,对于一个记录较多的DNS来说,会耽误更多的时间。
- 如果近修改一条记录,那么要重新加载或者重启BIND才能生效,那么需要时间,可能会影响客户端查询。
二.安装配置Bind-DLZ
#mkidr /usr/local/src/bind
#cd /usr/local/src/bind
#wget http://ftp.isc.org/isc/bind9/9.6.0-P1/bind-9.6.0-P1.tar.gz
#tar zxvf bind-9.6.0-P1.tar.gz
#cd bind-9.6.0-P1
1.编译安装 注 : 采用mysql做后台数据库,千万不能用?enable-threads选项启用多线程,网上有一些朋友使用mysql做后台,谈到bind会莫名中断服务,大部分都是因为打开了多线程。
2.创建相关配置文件 vi localhost.zone
ttl 86400 dig > named.root
3.在named.conf中添加DLZ相关的设置
#vi named.conf //在后面添加如下
dlz "Mysql zone" {
database "mysql
{ host=127.0.0.1 dbname=dns ssl=false port=3306 user=root pass= } //数据库相关连接账号,注意填写正确.
{select zone from dns_records where zone = '%zone%' limit 1}
{select ttl, type, mx_priority, case when lower(type)='txt' then concat('\"', data, '\"')
else data end from dns_records where zone = '%zone%' and host = '%record%'
and not (type = 'SOA' or type = 'NS')}
{select ttl, type, mx_priority, data, resp_person, serial, refresh, retry, expire, minimum
from dns_records where zone = '%zone%' and (type = 'SOA' or type='NS')}
{select ttl, type, host, mx_priority, data, resp_person, serial, refresh, retry, expire,
minimum from dns_records where zone = '%zone%' and not (type = 'SOA' or type = 'NS')}
{select zone from xfr_table where zone = '%zone%' and client = '%client%'}
{update data_count set count = count + 1 where zone ='%zone%'}";
};
4. 创建DNS数据库 建一个表dns_records 5.在在终端启动调试bind服务
[root@lemp ~]# /usr/local/bind/sbin/named -uroot -g -d 1
/usr/local/bind/sbin/named: error while loading shared libraries: libmysqlclient.so.16 //出错
#ln -s /usr/local/mysql/lib/mysql/libmysqlclient.so.16 /usr/lib/ //建立链链接即可.
#ldconfig
# /usr/local/bind/sbin/named -uroot -g -d 1 //无报错信息,继续如下.
三.添加相关记录并进行测试.
1.#zone anlegen:
--soa --linuxtone.org redirection for any host to linuxtone.org. --nameserver for zone --toplevel-ip-address of zone itself 2.#host anlegen:
--ip nameserver (resp_person can be NULL) A: www.linuxtone.org A:bbs.linuxtone.org 3.#host alias anlegen:
--ns2 directs to ns1 alias:man.linuxtone.org cname www alias: host.linuxton.org cname bbs 4.#mailserver anlegen:
--ns2 directs to ns1 四.相关表结构及bind查询测试.
1.表结构:
2.查询测试(增加记录实时生效,再也不要像以前一样重启相关配置文件了.)
附:
我的表结构和相关数据:{请下载}
named.conf配置文件:
四.启动脚本(增加named进程数,提高性能!)
1.创建多个named.conf配置文件
2.启动脚本
[root@lemp etc]# vi /etc/init.d/named
#!/bin/bash
# named a network name service.
# chkconfig: 345 35 75
# description: a name server
# http://www.linuxtone.org
if [ `id -u` -ne 0 ]
then
echo "ERROR:For bind to port 53,must run as root."
exit 1
fi
case "$1" in
start)
if [ -x /usr/local/bind/sbin/named ]; then
for i in `seq 1 8`
do
/usr/local/bind/sbin/named -c /usr/local/bind/etc/named1$i.conf -u root
echo "BIND9-named1$i server started"
done
fi
;;
stop)
kill `cat /usr/local/bind/var/named.pid` && echo . && echo 'BIND9 server stopped'
;;
restart)
echo .
echo "Restart BIND9 server"
$0 stop
sleep 10
$0 start
;;
reload)
/usr/local/bind/sbin/rndc reload
;;
status)
/usr/local/bind/sbin/rndc status
;;
*)
echo "$0 start | stop | restart |reload |status"
;;
esac
http://bbs.linuxtone.org/thread-2008-1-1.html