bind+dlz+mysql實現地區記錄動態更新

來源:互聯網
上載者:User

標籤:

BIND-DLZ實驗:http://bind-dlz.sourceforge.net/實驗環境:RHEL4,BIND-9.5.0-P2.tar.gz(9.4.0以上版本都已含DLZ補丁),Mysql-5.0.56.tar.gz1、安裝mysql(先安裝gcc等相關軟體包)   #tar zxvf mysql-5.0.56.tar.gz 
   #cd mysql-5.0.56
   #./configure --prefix=/usr/local/mysql --localstatedir=/usr/loal/mysql/data --   libexecdir=/usr/local/mysql/lib --disable-shared
   #make
   #make install
   #cd /usr/local/mysql/
   #groupadd -g 1003 mysql
   #useradd -g 1003 mysql
   #chown -R mysql .
   #chgrp -R mysql .
   #chown -R mysql lib
   #./bin/mysql_install_db --user=mysql //以mysql的使用者身份安裝
   #chown -R root .
   #./bin/mysqld_safe --user=mysql & //在後台啟動mysql

# cd /root/mysql-5.0.56
# cp support-files/my-medium.cnf /etc/my.cnf
# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
# chmod 700 !$
# chkconfig --add mysqld
# chkconfig --list mysqld
  mysqld 1:off 2:on 3:on 4:on 5:on 6:off
# service mysqld start[restart/reload/stop]
# vi /etc/my.cnf
 add this:(防止mysql伺服器無查詢後8小時自動重連)
wait_timeout = 86400

interactive_timeout = 86400

   #/usr/local/mysql/bin/mysqladmin -uroot password ‘aptech‘
   #./bin/mysql -uroot -paptech   #echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile   #. !$  2、安裝bind   #tar zxvf bind-9.5.0-P2.tar.gz 
   #cd bind-9.5.0-P2
   #./configure --prefix=/usr/local/bind9 --with-dlz-mysql=/usr/local/mysql --enable-threads=no   //--with-dlz-mysql=/usr/local/mysql 要求bind安裝中支援DLZ   //--enable-threads=no 關閉多線程    //--disable-openssl-version-check 禁止openssl版本的檢查
   #make
   #make install

3、建立database,table   create database mydata;   use mydata;   create table other_dns_records(   zone varchar(255),   host varchar(255),   type varchar(255),   data varchar(255),   ttl int(11),   mx_priority varchar(255),    refresh int(11),   retry int(11),   expire int(11),   minimum int(11),   serial bigint(11),   resp_person varchar(255),    primary_ns varchar(255));    create table cnc_dns_records(   host varchar(255),   type varchar(255),   data varchar(255),   ttl int(11),   mx_priority varchar(255),    refresh int(11),   retry int(11),   expire int(11),   minimum int(11),   serial bigint(11),   resp_person varchar(255),    primary_ns varchar(255));     insert other_dns_records(zone,host,type,data,ttl,retry)   values(‘aaa.com‘,‘www‘,‘A‘,‘192.168.199.2‘,‘86400‘,‘13‘);   insert cnc_dns_records(zone,host,type,data,ttl,retry)   values(‘bbb.com‘,‘www‘,‘A‘,‘192.55.199.199‘,‘86400‘,‘13‘);4、編輯/usr/local/bind9/etc/named.conf   #cd /usr/local/bind9/etc   #../sbin/rndc-confgen -a   #../sbin/rndc-confgen > named.conf   #vi !$   //vi named.conf   #less named.conf # Use with the following in named.conf, adjusting the allow list as needed:
 key "rndc-key" {
        algorithm hmac-md5;
        secret "c4aUV+N7GbOF773V+/LnAA==";
 };
 
 controls {
        inet 127.0.0.1 port 953
                allow { 127.0.0.1; } keys { "rndc-key"; };
 };
# End of named.conf
options {
directory "/usr/local/bind9/etc/";
pid-file "/usr/local/bind9/var/run/named.pid";
allow-query { any; };
recursion no;
version "gaint-d1";
};
include "/usr/local/bind9/etc/cnc.cl";
include "/usr/local/bind9/etc/other.cl";
view "cnc-user" {
match-clients { cnc; };
dlz "Mysql zone" {
database "mysql
{host=localhost dbname=mydata ssl=false port=3306 user=root pass=aptech}
{select zone from cnc_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 as mydata from
cnc_dns_records where zone = ‘%zone%‘ and host = ‘%record%‘}";
};
};
view "other-user" {
match-clients { other; };
dlz "Mysql zone" {
database "mysql
{host=localhost dbname=mydata ssl=false port=3306 user=root pass=aptech}
{select zone from other_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 as mydata from
other_dns_records where zone = ‘%zone%‘ and host = ‘%record%‘}";
};
};
[[email protected] etc]# less cnc.cl 
acl "cnc"{
192.168.9.0/24;
};
[[email protected] etc]# less other.cl 
acl "other" {
127.0.0.0/18;
}; 5、啟動&測試[[email protected] ~]# /usr/local/bind9/sbin/named -gc  /usr/local/bind9/etc/named.conf
06-Mar-2009 22:23:02.569 starting BIND 9.5.0-P2 -gc /usr/local/bind9/etc/named.conf
06-Mar-2009 22:23:02.579 loading configuration from ‘/usr/local/bind9/etc/named.conf‘
06-Mar-2009 22:23:02.583 listening on IPv4 interface lo, 127.0.0.1#53
06-Mar-2009 22:23:02.586 listening on IPv4 interface eth0, 192.168.1.5#53
06-Mar-2009 22:23:02.588 Loading ‘Mysql zone‘ using driver mysql
06-Mar-2009 22:23:02.604 default max-cache-size (33554432) applies: view cnc-user
06-Mar-2009 22:23:02.609 Loading ‘Mysql zone‘ using driver mysql
06-Mar-2009 22:23:02.612 default max-cache-size (33554432) applies: view other-user
06-Mar-2009 22:23:02.616 default max-cache-size (33554432) applies: view _bind
06-Mar-2009 22:23:02.621 command channel listening on 127.0.0.1#953
06-Mar-2009 22:23:02.621 ignoring config file logging statement due to -g option
06-Mar-2009 22:23:02.623 running
注:加-gc參數可顯示出開機記錄,以便出錯排查;顯示running表示配置正確.
來源: http://blog.chinaunix.net/uid-10435474-id-2957057.html

來自為知筆記(Wiz)

bind+dlz+mysql實現地區記錄動態更新

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.