日期:2014-05-16  浏览次数:20870 次

bind dlz mysql的配置
部分配置
配置文件name.conf
logging {
        channel query_log {
                file "/byread/logs/bind/query.log"        versions 3 size 20m;
                severity                info;
                print-time              yes;
                print-category  yes;
        };
        category queries {
                query_log;
        };


include "/byread/bin/bind/etc/cmcc.ip";
include "/byread/bin/bind/etc/tel.ip";
include "/byread/bin/bind/etc/cnc.ip";
include "/byread/bin/bind/etc/view.conf";


[root@dns_telecom etc]# more cmcc.ip 
acl "cmcc" {
36.128.0.0/10;
111.0.0.0/10;
112.0.0.0/10;
117.128.0.0/10;
120.192.0.0/10;
121.36.0.0/16;
121.37.0.0/16;
183.192.0.0/10;
202.0.176.0/22;
202.70.0.0/19;
203.86.0.0/19;
203.128.96.0/19;
211.103.0.0/17;
211.136.0.0/14;
211.140.0.0/15;
211.142.0.0/17;
211.142.128.0/17;
211.143.0.0/16;
218.200.0.0/14;
218.204.0.0/15;
218.206.0.0/15;
220.231.128.0/17;
221.130.0.0/15;
221.176.0.0/13;
223.64.0.0/10;
};


[root@dns_telecom etc]# more view.conf
view "cmcc_view" {
 
 match-clients           { cmcc; };
 allow-query-cache       { any; };
 allow-recursion         { any; };
 allow-transfer          { none; };
 recursion               yes;
 
 dlz "Mysql zone" {
   database "mysql
   {host=****** dbname=****** ssl=false port=****** user=****** pass=****** }
   {select zone from dns_records where (( host='@' and zone = '$zone$' ) or (host!='@' and type='NS' and concat(host,'.',zone)='$zone$' )) and view='cmcc' limit 1}
   {select ttl, type, mx_priority, case when lower(type)='txt' then concat('\"', data, '\"') else data end as data from dns_records where zone = '$zone$' and host = '$record$' and view='cmcc' and type <> 'NS' and type <> 'SOA'}
   {select ttl, type, data, resp_person, serial, refresh, retry, expire, minimum from dns_records where ((host = '@' and zone = '$zone$') OR (host != '@' and concat(host,'.',zone) = '$zone$')) and (type = 'SOA' OR type='NS') order by typ
e='SOA' desc}
   {select ttl, type, host, mx_priority, case when lower(type)='txt' then concat('\"', data, '\"') else data end as data, resp_person, serial, refresh, retry, expire, minimum from dns_records where zone = '$zone$' and view='cmcc' and typ
e <> 'NS' and type <> 'SOA'}
   {select zone from xfr_table where zone = '$zone$' and client = '$client$' and view='cmcc' limit 1}
   {update data_count set count = count + 1 where zone ='$zone$' and view='cmcc'}";
 };
 
};



dns_records表记录
INSERT INTO `dns_records` VALUES 
(27,'client.byread.com','@','A','61.155.8.68',3600,'tel','',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2011-03-17 11:13:06','1'),
(28,'client.byread.com','@','A','111.1.37.147',3600,'cmcc','',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2011-03-17 11:14:27','1'),
(29,'client.byread.com','@','A','122.192.36.71',3600,'cnc','',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2011-03-17 11:14:38','1'),
(30,'client.byread.com','sukai','A','61.155.8.68',3600,'tel','',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2011-03-15 14:50:46','1'),
(31,'client.byread.com','sukai','A','111.1.37.147',3600,'cmcc','',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2011-03-15 14:51:01','1'),
(32,'client.byread.com','sukai','A','122.192.36.71',3600,'cnc','',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2011-03-15 14:51:32','1'),
(34,'client.byread.com','@','NS','ns.client.byread.com.',3600,'tel','',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2011-03-18 15:45:45','1'),
(35,'client.byread.com','ns','A','61.155.236.134',3600,'tel','',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2011-03-18 15:45:57','1'),
(36,'client.byread.com','@','SOA','ns.client.byread.com.',3600,'tel',NULL,10800,900,691200,50000,2011032009,'ycsk02.hotmail.com.',NULL,NULL,NULL,NULL),
(39,