bind9 dlz mysql 配置

栏目: 数据库 · Mysql · 发布时间: 7年前

内容简介:bind9 dlz mysql 配置

1.数据库安装

yum -y install mysql-community-server mysql-community-devel

2.编译安装bind 一些基础的包,请参考前一章

./configure –with-dlz-mysql –enable-largefile –enable-threads=no –prefix=/migu/bind –with-libtool –enable-epoll –with-openssl

make -j 8 && make -j 8 install

3.数据库初始化:

CREATE SCHEMA `bind` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;

CREATE TABLE IF NOT EXISTS `dns_records` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `zone` varchar(255) NOT NULL,
  `host` varchar(255) NOT NULL DEFAULT '@',
  `type` enum('A','MX','CNAME','NS','SOA','PTR','TXT','AAAA','SVR','URL') NOT NULL,
  `data` varchar(255) DEFAULT NULL,
  `ttl` int(11) NOT NULL DEFAULT '3600',
  `mx_priority` int(11) DEFAULT NULL,
  `view`  enum('any', 'CHINANET', 'Unicom', 'CNC', 'ours') NOT NULL  DEFAULT "any" ,
  `priority` tinyint UNSIGNED NOT NULL DEFAULT '255',
  `refresh` int(11) NOT NULL DEFAULT '28800',
  `retry` int(11) NOT NULL DEFAULT '14400',
  `expire` int(11) NOT NULL DEFAULT '86400',
  `minimum` int(11) NOT NULL DEFAULT '86400',
  `serial` bigint(20) NOT NULL DEFAULT '2015050917',
  `resp_person` varchar(64) NOT NULL DEFAULT 'ddns.net',
  `primary_ns` varchar(64) NOT NULL DEFAULT 'ns.ddns.net.',
  PRIMARY KEY (`id`),
  KEY `type` (`type`),
  KEY `host` (`host`),
  KEY `zone` (`zone`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

插入SOA数据:

INSERT INTO `dns_records` (`zone`, `host`, `type`, `data`, `ttl`,`mx_priority`,  `refresh`, `retry`, `expire`, `minimum`, `serial`, `resp_person`, `primary_ns`) VALUES  (‘xieyugui.com’, ‘@’, ‘SOA’, ‘ns1.xieyugui.com.’, 10, NULL, 600, 3600, 86400, 10, 2017060801, ‘root.xieyugui.com.’, ‘ns1.xieyugui.com.’);

插入@ NS数据:

INSERT INTO `dns_records` (`zone`, `host`, `type`, `data`) VALUES  (‘xieyugui.com’, ‘@’, ‘NS’, ‘ns1.xieyugui.com.’),  (‘xieyugui.com’, ‘@’, ‘NS’, ‘ns2.xieyugui.com.’);

插入NS A数据:

INSERT INTO `dns_records` (`zone`, `host`, `type`, `data`) VALUES  (‘xieyugui.com’, ‘ns1’, ‘A’, ‘192.168.10.5’),  (‘xieyugui.com’, ‘ns2’, ‘A’, ‘192.168.1.111’);

插入www A记录:

INSERT INTO `dns_records` (`zone`, `host`, `type`, `data`, `ttl`, `view`) VALUES  (‘xieyugui.com’, ‘www’, ‘A’, ‘192.168.1.111’, 360, ‘any’),  (‘xieyugui.com’, ‘app’, ‘A’, ‘192.168.1.112’, 360, ‘CHINANET’),  (‘xieyugui.com’, ‘dev’, ‘A’, ‘192.168.1.113’, 360, ‘any’),  (‘xieyugui.com’, ‘db’, ‘A’, ‘192.168.1.114’, 360, ‘any’);

插入CNAME 记录:

INSERT INTO dns_records (zone,host,type,DATA,view) VALUES  (‘xieyugui.com’, ‘blog’, ‘CNAME’, ‘www’,’CNC’);

5.etc 目录结构

[root@TEST_MASTER etc]# ls

acl   keys   named.conf   rndc.conf   view.conf   zone

wget http://www.centos.bz/wp-content/uploads/2012/02/CHINANET.acl ./acl/

wget http://www.centos.bz/wp-content/uploads/2012/02/CNC.acl ./acl/

vim named.conf

include “/migu/bind/etc/acl/CHINANET.acl” ;

include “/migu/bind/etc/acl/CNC.acl” ;    

include “/migu/bind/etc/view.conf”

vim view.conf

view “CHINANET_view” {

match-clients   { CHINANET; };

allow-query-cache { none; };

allow-recursion { none; };

allow-transfer { none; };

recursion no;

dlz “Mysql zone” {

database “mysql

{host=127.0.0.1 dbname=bind ssl=false port=3306 user=root pass=xxx}

{select zone from dns_records where zone = ‘$zone$’ and   view = ‘any’ 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=(select view from dns_records where zone = ‘$zone$’ and host = ‘$record$’ and (view=’CHINANET’ or view=’any’) order by priority asc limit 1)}”;

};

};

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=bind ssl=false port=3306 user=root pass=xxx}

{select zone from dns_records where zone = ‘$zone$’ and   view = ‘any’ 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=(select view from dns_records where zone = ‘$zone$’ and host = ‘$record$’ and (view=’CNC’ or view=’any’) order by priority asc limit 1)}”;

};

};

view “any_view” {

match-clients   { any; };

allow-query-cache { none; };

allow-recursion { none; };

allow-transfer { none; };

recursion no;

dlz “Mysql zone” {

database “mysql

{host=127.0.0.1 dbname=bind ssl=false port=3306 user=root pass=xxx}

{select zone from dns_records where zone = ‘$zone$’ and   view = ‘any’ 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 = ‘any’}”;

};

} ;

貌似上面的view.conf里面的select逻辑有点问题,但是整体还是能跑通的,后面有空再整理一下

bind9 dlz mysql 配置


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

硅谷之火

硅谷之火

迈克尔·斯韦因 / 王建华 / 机械工业出版社 / 2001-1-1 / 34.00

我们今天正处于这样一个时代:充满幻想的人们发现他们获得了他们曾经梦寐以求的力量,并且可以利用这个力量来改造我们的世界。 这是个转折的时代,跨国公司迷失了发展方向,而小企业家却举起了计算机革命的大旗,成了开拓未来的先锋。在这个时代里,计算机奇才的脸上露出了胜利的微笑,胸怀 大志者成了富有理想的人,而富有理想的人则成了亿万富翁。这是一场真正的革命,它促使人们变得伟大,变得富有而充满理想,自豪而富......一起来看看 《硅谷之火》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

随机密码生成器
随机密码生成器

多种字符组合密码

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具