系统环境:

系统:centos 6.8
Mysql: 5.1
BIND: bind-9.11.-P2.tar.gz
IP地址:192.168.153.130
软件下载地址:http://ftp.isc.org/

一、安装并配置MySQL.

1.编译环境相关依赖包安装.

yum install openssl-devel openldap-devel unixODBC-devel gcc

2.安装MySQL数据库

yum -y install mysql mysql-server mysql-devel

3.验证是否安装成功

[root@localhost ~]# rpm -qi mysql-server

4.启动MySql服务

[root@localhost ~]# /etc/init.d/mysqld start

5.登录并设置密码

[root@localhost ~]# mysql -u root
mysql> show databases;
mysql> use mysql;
mysql> update user set password=password('') where user='root';

6.开放远程登录权限

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '' WITH GRANT OPTION;
Query OK, rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, rows affected (0.00 sec)

7.设置开机启动(非必须)

[root@localhost ~]#chkconfig mysqld on

二、下载并安装Bind-DLZ

1.下载并解压Bind-DLZ软件包

[root@localhost opt]#wget http://ftp.isc.org/isc/bind9/9.11.0-P2/bind-9.11.0-P2.tar.gz
[root@localhost opt]#tar -zxvf bind-9.11.-P2.tar.gz

2.在64位系统上编译,您可能需要设置一些变量,以便找到适当的mysql库:

[root@localhost ~]# export CPPFLAGS="-I/usr/lib64/mysql $CPPFLAGS"
[root@localhost ~]# export LDFLAGS="-L/usr/lib64/mysql $LDFLAGS"
[root@localhost ~]# export LD_LIBRARY_PATH="/usr/lib64/mysql"

3.编译安装Bind-DLZ.

[root@localhost opt]# cd bind-9.11.-P2
[root@localhost bind-9.11.-P2]#./configure --prefix=/usr/local/bind --enable-threads \
--enable-largefile --disable-ipv6 \
--disable-openssl-version-check \
--with-dlz-mysql=yes
[root@localhost bind-9.11.-P2]# make
[root@localhost bind-9.11.-P2]# make install

4.查看版本并测试软件是否安装成功

[root@localhost bind-9.11.-P2]# /usr/local/bind/sbin/named -v
BIND 9.11.-P2 <id:>

5.配置rndc.conf和named.conf文件

生成rndc.conf:

[root@localhost ~]# cd /usr/local/bind/etc/
[root@localhost etc]# rndc-confgen -r /dev/urandom > rndc.conf

提供ca文件

[root@localhost etc]#wget -O named.ca  http://www.internic.net/domain/named.root

创建并生成named.conf

[root@localhost etc]#  tail - rndc.conf | head - | sed s/#\ //g > named.conf

生成的named.conf文件只key和controls部分,需要自己手动添加logging和options部分,完整文件如下:

[root@localhost etc]# cat named.conf
key "rndc-key" {
algorithm hmac-md5;
secret "X0k0Uz62Actu11IXrnA48A==";
};
controls {
inet 127.0.0.1 port
allow { 127.0.0.1; } keys { "rndc-key"; };
}; logging {
channel bind_log {
file "/tmp/bind.log" versions size 20m;
severity info;
print-time yes;
print-severity yes;
print-category yes;
};
category default {
bind_log; };
}; options {
listen-on port { 192.168.153.130; };
directory "/usr/local/bind";
Pid-file "named.pid";
allow-query-cache { any; };
allow-query { any; };
}; dlz "Mysql zone" {
database "mysql
{host=192.168.153.130 dbname=bind ssl=false port= user=root pass=}
{select zone from dns_records where zone = '$zone$' and view = 'any' limit }
{select ttl,type,if(mx_priority>,mx_priority,NULL),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'}";
};
[root@localhost etc]#

6.创建named用户,使bind服务以named用户运行,

[root@localhost ~]#groupadd -r -g  named
[root@localhost ~]#useradd -r -u -s /bin/nologin -d /usr/local/named -g named named
[root@localhost ~]#chown -R named:named /usr/local/bind/

7.前台启动named服务,看看配置是否正常.

[root@localhost ~]#/usr/local/bind/sbin/named -c /usr/local/bind/etc/named.conf -f -g -u named

如果以上的配置启动都没有报错,那么接下来就可以添加MySQL,这样就可以将区域信息写入到数据库中.

三、配置dlz数据库查询

1.登录MySQL,并创建库和表.

mysql> create database bind;
Query OK, row affected (0.00 sec)
> CREATE TABLE IF NOT EXISTS `dns_records` (
`id` int() unsigned NOT NULL AUTO_INCREMENT,
`zone` varchar() NOT NULL,
`host` varchar() NOT NULL DEFAULT '@',
`type` enum('A','MX','CNAME','NS','SOA','PTR','TXT','AAAA','SVR','URL') NOT NULL,
`data` varchar() DEFAULT NULL,
`ttl` int() NOT NULL DEFAULT '',
`mx_priority` int() DEFAULT NULL,
`view` enum('any', 'Telecom', 'Unicom', 'CMCC', 'ours') NOT NULL DEFAULT "any" ,
`priority` tinyint UNSIGNED NOT NULL DEFAULT '',
`refresh` int() NOT NULL DEFAULT '',
`retry` int() NOT NULL DEFAULT '',
`expire` int() NOT NULL DEFAULT '',
`minimum` int() NOT NULL DEFAULT '',
`serial` bigint() NOT NULL DEFAULT '',
`resp_person` varchar() NOT NULL DEFAULT 'ddns.net',
`primary_ns` varchar() 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= ; Query OK, rows affected (0.02 sec)

2.数据库中插入数据:

mysql> insert into bind.dns_records (zone, host, type, data, ttl) VALUES ('testinfo.com', 'www', 'A', '1.1.1.1', '');
Query OK, row affected (0.00 sec) mysql> insert into bind.dns_records (zone, host, type, data, ttl) VALUES ('testinfo.com', 'bbs', 'A', '2.2.2.2', '');
Query OK, row affected (0.00 sec) mysql> insert into bind.dns_records (zone, host, type, data, ttl) VALUES ('testinfo.com', 'm', 'A', '3.3.3.3', '');
Query OK, row affected (0.00 sec) mysql>

3.后台启动named服务:

[root@localhost ~]# /usr/local/bind/sbin/named -c /usr/local/bind/etc/named.conf -f -g -u named &

4.在/etc/resolv.conf 文件中添加本机192.168.153.130为第一dns解析地址:

[root@localhost ~]# vim /etc/resolv.conf
; generated by /sbin/dhclient-script
#search localdomain
nameserver 192.168.153.130
nameserver 192.168.153.2
nameserver 8.8.8.8

5.解析测试:本地添加的test.info.com域名通过192.168.153.130解析,外网的www.baidu.com使用第二个dns解析.

[root@localhost ~]# nslookup
> www.testinfo.com
Server: 192.168.153.130
Address: 192.168.153.130# Name: www.testinfo.com
Address: 1.1.1.1
> bbs.testinfo.com
Server: 192.168.153.130
Address: 192.168.153.130# Name: bbs.testinfo.com
Address: 2.2.2.2
> m.testinfo.com
Server: 192.168.153.130
Address: 192.168.153.130# Name: m.testinfo.com
Address: 3.3.3.3
> www.baidu.com
Server: 192.168.153.2
Address: 192.168.153.2# Non-authoritative answer:
www.baidu.com canonical name = www.a.shifen.com.
Name: www.a.shifen.com
Address: 220.181.111.188
Name: www.a.shifen.com
Address: 220.181.112.244

至此Bind-MySQL部署完成.

参考文档:

    https://itsecureadmin.com/2010/09/bind-dlz-with-mysql/

    https://www.jianshu.com/p/1318ef8865ba

    https://www.cnblogs.com/jiangxu67/p/4801230.html  

Bind-DLZ with MySQL的更多相关文章

  1. Bind+DLZ+MySQL智能DNS的正向解析和反向解析实现方法

    使用文本配置文件的配置方式结合bind的最新的acl和view特性来实现智能DNS想必很多人已经很熟悉了,使用MySQL数据库来存放zone文件的方式可能也不少.对于两者都熟悉的,实现 Bind+DL ...

  2. Bind+DLZ构建企业智能DNS/DNS

    Bind+DLZ构建企业智能DNS   目录:一.简介二.服务规划三.安装BIND及基本环境四.配置Bind-View-DLZ-MYSQL五.添加相关记录并进行测试六.配置从DNS七.补充 一.简介: ...

  3. bind+dlz+mysql实现区域记录动态更新

    BIND-DLZ实验:http://bind-dlz.sourceforge.net/ 实验环境:RHEL4,BIND-9.5.0-P2.tar.gz(9.4.0以上版本都已含DLZ补丁),Mysql ...

  4. bind智能DNS + bindUI管理系统(postgresql + bind dlz)

    # 软件环境: * Centos 7.6 * bind-9.14.1.tar.gz * postgresql 11 * python 3.7 * django 2.2.1 QPS:单节点1590 qp ...

  5. bind9+dlz+mysql连接断开问题

    前言 关于bind-dlz介绍:http://bind-dlz.sourceforge.net/ DLZ(Dynamically Loadable Zones)与传统的BIND9不同,BIND的不足之 ...

  6. BIND DNS拒绝服务漏洞 CVE-2016-2776修复

    接到此漏洞之后,略微查了一下相关描述,发现漏洞影响范围很大,可能造成的影响也很严重,于是着手进行修复. 漏洞的详细信息可见如下链接: http://www.cnvd.org.cn/flaw/show/ ...

  7. Docker搭建MySQL主从复制

    Docker搭建MySQL主从复制 主从服务器上分别安装Docker 1.1 Docker 要求 CentOS 系统的内核版本高于 3.10 [root@localhost ~]# uname -r ...

  8. 配置NAT回流导致外网解析到了内网IP

    单位有3个域名,用量很大,2014年开始本人研究部署了Bind+DLZ +Mysql的三机智能多链路DNS,非常好用,优点是: 1.使用Mysql管理记录,配置.管理.查询方便. 2.自动判断运营商, ...

  9. 我要为运维说一句,我们不是网管,好不!!Are you know?

    运维 运维,这里指互联网运维,通常属于技术部门,与研发.测试.系统管理同为互联网产品技术支撑的4大部门,这个划分在国内和国外以及大小公司间都会多少有一些不同. 一个互联网产品的生成一般经历的过程是:产 ...

  10. [docker]bind9.11-with-mysql5.6 docker容器化实战

    参考: https://www.centos.bz/2012/09/bind-with-mysql-support/ http://blog.51niux.com/?id=125 http://470 ...

随机推荐

  1. WeakReference 学习和使用

    本文转自:http://qifuguang.me/2015/09/02/[Java%E5%B9%B6%E5%8F%91%E5%8C%85%E5%AD%A6%E4%B9%A0%E4%B8%83]%E8% ...

  2. Faiss教程:入门

    Faiss处理固定维度d的数据,矩阵每一行表示一个向量,每列表示向量的一项.Faiss采用32-bit浮点型存储. 假设xb为数据集,维度为\(nb\times{d}\):xq是查询数据,维度为\(n ...

  3. button上传替换file上传按钮,并显示图片缩略图,纯jsp操作

    1.jsp代码 <div class="inputBox"> <span id="tu" <c:if test="${pd = ...

  4. Android 下拉刷新上啦加载SmartRefreshLayout + RecyclerView

    在弄android刷新的时候,可算是耗费了一番功夫,最后发觉有现成的控件,并且非常好用,这里记录一下. 原文是 https://blog.csdn.net/huangxin112/article/de ...

  5. APUE信号-程序汇总

    APUE信号-程序汇总      近期重看APUE,发现对于非常多程序的要领还是没有全然理解.所以梳理下便于查看,并且有非常多值得思考的问题. 程序清单10- 1  捕获 SIGUSR1 和 SIGU ...

  6. cacti监控jvm

    jdk环境 java version "1.6.0_37" Java(TM) SE Runtime Environment (build 1.6.0_37-b06) Java Ho ...

  7. C++中cin的用法汇总

    cin可以用于接收输入,最常见的是从控制台接收.在刚学习C++的时候经常会用cin来接收数据,这里想要系统的总结一下cin的用法,保证不灌水. C++中的cin是一个 istream对象,从标准输入中 ...

  8. [mount]linux 挂载时 mount: wrong fs type, bad option, bad superblock on /dev/sdb

    原因:挂载时未格式化,使用的文件系统格式不对 解决方案:格式化 sudo mkfs -t ext4 /dev/sdb 再挂载 sudo mount /dev/sdb /xxx/ 用df -h检查,发现 ...

  9. Selenium (3) —— Selenium IDE + Firefox录制登录脚本(101 Tutorial)

    Selenium (3) -- Selenium IDE + Firefox录制登录脚本(101 Tutorial) selenium IDE版本: 2.9.1 firefox版本: 39.0.3 参 ...

  10. svn 备份脚本

    [root@hm-vpnserver-196 ~]# cat /root/svnback.sh #!/bin/bashtt=$(ls /home/svndata/) for i in $ttdo mk ...