三、安裝配置Bind-DLZ 1、編譯安裝MySQL 在此不作介紹,具體的請看http://www.linuxtone.org 相關內容。 注意編譯MySQL的時候禁掉線程,相關的參數如下:--without-server --disable-threads --without-pthread2、編譯安裝Bind#mkdir /usr/local/src/bind-dlz #cd /usr/local/src/bind-dlz #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#./configure --with-dlz-mysql --enable-largefile --enable-threads=no --prefix=/usr/local/bind --with-openssl=/usr/local/openssl/註:禁掉線程;--with-openssl= 你的openssl安裝的相關目錄有可能是/usr# make && make install創建相關配置文件cd /usr/local/bind/etc ../sbin/rndc-confgen >rndc.conf tail -n10 rndc.conf | head -n9 | sed -e s/#\//g >named.conf# vi localhost.zonettl 86400 @ IN SOA localhost. root.localhost. ( 1997022700 ; Serial 28800 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Minimum IN NS localhost. 1 IN PTR localhost. # dig > named.root #vi named.conf 在後面加入如下: include "/usr/local/bind/etc/cnc_acl.conf"; //網通ACL include "/usr/local/bind/etc/telecom_acl.conf"; //電信ACL include "/usr/local/bind/etc/edu_acl.conf"; //教育網ACL include "/usr/local/bind/etc/view.conf"; //DLZ相關的配置#vi /usr/local/bind/etc/view.conf //創建view相關的配置文件 #cnc-view //貼出其中網通部分的範例,更詳細的請參照view.conf配置文件.view "cnc_view" { match-clients { CNC; }; allow-query-cache { none; }; allow-recursion { none; }; allow-transfer { none; }; recursion no; dlz "Mysql zone" { database "mysql {host=127.0.0.1 dbname=cdn_view ssl=false port=3306 user=root pass= } {select zone from dns_records where zone = '%zone%' and view='CNC' limit 1} {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 as mydata from dns_records where zone = '%zone%' and host = '%record%' and view='CNC'} {} {select ttl, type, host, mx_priority, case when lower(type)='txt' then concat('\"', data, '\"') else data end as mydata, resp_person, serial, refresh, retry, expire, minimum from dns_records where zone = '%zone%' and view='CNC'} {select zone from xfr_table where zone = '%zone%' and client = '%client%' and view='CNC' limit 1} {update data_count set count = count + 1 where zone ='%zone%' and view='CNC'}"; }; };官方相關參考請參照: http://bind-dlz.sourceforge.net/mysql_example.html
3、DLZ相關資料庫表結構建立 (//詳細見提供的cdn_view.sql含測試數據.)mysql>create database cdn_view; //創建資料庫名為cdn_view mysql>use cdn_view; CREATE TABLE `dns_records` ( `id` int(10) unsigned NOT NULL auto_increment, `zone` varchar(255) NOT NULL, `host` varchar(255) NOT NULL default '@', `type` enum('MX','CNAME','NS','SOA','A','PTR') NOT NULL, `data` varchar(255) default NULL, `ttl` int(11) NOT NULL default '800', `view` enum('CNC','TELECOM','EDU','ANY') NOT NULL, //智能DNS區域範圍 `mx_priority` int(11) default NULL, `refresh` int(11) NOT NULL default '3600', `retry` int(11) NOT NULL default '3600', `expire` int(11) NOT NULL default '86400', `minimum` int(11) NOT NULL default '3600', `serial` bigint(20) NOT NULL default '2008082700', `resp_person` varchar(64) NOT NULL default 'root.domain.com.', `primary_ns` varchar(64) NOT NULL default 'ns1.domain.com.', `data_count` int(11) NOT NULL default '0', PRIMARY KEY (`id`), KEY `type` (`type`), KEY `host` (`host`), KEY `zone` (`zone`) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; #desc dns_records; 顯示錶結構.