博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
bind9+mysql dlz(Dynamically Loadable Zones)
阅读量:4947 次
发布时间:2019-06-11

本文共 4801 字,大约阅读时间需要 16 分钟。

yum install openssl openssl-devel

groupadd mysql
useradd -g mysql -s /sbin/nologin -M mysql
chown -R mysql:mysql /usr/local/mysql
./configure  --prefix=/usr/local/mysql/ --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client -with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase,myisammrg
make && make install
/usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var --user=mysql
cd /usr/local/mysql
cp share/mysql/my-medium.cnf /etc/my.cnf
nohup ./mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --datadir=/usr/local/mysql/var &
登录mysql /usr/local/mysql/bin/mysql
insert into mysql.user(Host,User,Password) values("localhost","dns",password("dns"));
insert into mysql.user(Host,User,Password) values("%","dns",password("dns"));
GRANT ALL PRIVILEGES ON *.* TO 'dns'@'%' IDENTIFIED BY 'dns' WITH GRANT OPTION;
flush privileges;
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') NOT NULL,
  `data` varchar(255) default NULL,
  `ttl` int(11) NOT NULL default '800',
  `mx_priority` varchar(255) default NULL,
  `refresh` int(11) default NULL,
  `retry` int(11) default NULL,
  `expire` int(11) default NULL,
  `minimum` int(11) default NULL,
  `serial` bigint(20) default NULL,
  `resp_person` varchar(255) default NULL,
  `primary_ns` varchar(255) default NULL,
  PRIMARY KEY  (`id`),
  KEY `id` (`id`),
  KEY `type` (`type`),
  KEY `host` (`host`),
  KEY `zone` (`zone`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
--soa
INSERT INTO dns_records (zone,host,type,serial,refresh,retry,expire,minimum,primary_ns,resp_person)
VALUES ('linuxtone.org', '@', 'SOA', 2009030200, 172800, 800, 1209600, 3600 , 'ns1.linuxtone.org', 'root.linuxtone.org.');
--linuxtone.org redirection for any host to linuxtone.org.
INSERT INTO dns_records (zone,host,type,DATA)
VALUES ('linuxtone.org', '*', 'CNAME', 'linuxtone.org.');
--nameserver for zone
INSERT INTO dns_records (zone,host,type,DATA)
VALUES ('linuxtone.org', '@', 'NS', 'ns1.linuxtone.org.');
--toplevel-ip-address of zone itself
INSERT INTO dns_records (zone,host,type,DATA)
VALUES ('linuxtone.org', '@', 'A', '192.168.0.103');
2.#host anlegen:
--ip nameserver (resp_person can be NULL)
INSERT INTO dns_records (zone,host,type,DATA,resp_person)
VALUES ('linuxtone.org', 'ns1', 'A', '192.168.0.103', 'root.linuxtone.org.');
A:www.linuxtone.org
INSERT INTO dns_records (zone,host,type,DATA)
VALUES ('linuxtone.org', 'www', 'A', '192.168.0.108');
A:bbs.linuxtone.org
INSERT INTO dns_records (zone,host,type,DATA)
VALUES ('linuxtone.org', 'bbs', 'A', '192.168.0.109');
3.#host alias anlegen:
--ns2 directs to ns1
INSERT INTO dns_records (zone,host,type,DATA,resp_person)
VALUES ('linuxtone.org', 'ns2', 'CNAME', 'ns1.linuxtone.org.', 'root.linuxtone.org.');
alias:man.linuxtone.org cname www
INSERT INTO dns_records (zone,host,type,DATA)
VALUES ('linuxtone.org', 'man', 'CNAME', 'www');
alias: host.linuxton.org cname bbs
INSERT INTO dns_records (zone,host,type,DATA)
VALUES ('linuxtone.org', 'host', 'CNAME', 'bbs.linuxtone.org.');
4.#mailserver anlegen:
--ns2 directs to ns1
INSERT INTO dns_records (zone,host,type,DATA,mx_priority, resp_person)
VALUES ('linuxtone.org', '*', 'MX', 'mail.linuxtone.org.', '80', 'root.linuxtone.org.');
安装bind,9.4.0以上版本都有DLZ补丁了,DLZ(Dynamically Loadable Zones),允许区域记录放置在数据库中,并且支持多种数据库。
./configure --with-dlz-mysql --enable-largefile --enable-threads=no --prefix=/usr/local/bind --disable-openssl-version-check
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
dig > named.root  //这一步没做成功也没关系 貌似
vi /usr/local/bind/etc/named.conf
dlz "Mysql zone" {
   database "mysql
   {host=127.0.0.1 dbname=dns ssl=false port=3306 user=root pass= }  
   {select zone from dns_records where zone = '$zone$' limit 1}
   {select ttl, type, mx_priority, case when lower(type)='txt' then concat('\"', data, '\"')
        else data end from dns_records where zone = '$zone$' and host = '$record$'
        and not (type = 'SOA' or type = 'NS')}
   {select ttl, type, mx_priority, data, resp_person, serial, refresh, retry, expire, minimum
        from dns_records where zone = '$zone$' and (type = 'SOA' or type='NS')}
   {select ttl, type, host, mx_priority, data, resp_person, serial, refresh, retry, expire,
        minimum from dns_records where zone = '$zone$' and not (type = 'SOA' or type = 'NS')}
   {select zone from xfr_table where zone = '$zone$' and client = '$client$'}
   {update data_count set count = count + 1 where zone ='$zone$'}";
};
启动
/usr/local/bind/sbin/named -c /usr/local/bind/etc/named.conf

转载于:https://www.cnblogs.com/fanweiwei/p/4094958.html

你可能感兴趣的文章
模块化导出
查看>>
pagebean pagetag java 后台代码实现分页 demo 前台标签分页 后台java分页
查看>>
Sphinx 2.0.8 发布,全文搜索引擎 Installing Sphinx on Windows
查看>>
pod
查看>>
ResultSet 可滚动性和可更新性
查看>>
VS2013 C++代码运行问题
查看>>
iOS 加载图片选择imageNamed 方法还是 imageWithContentsOfFile?
查看>>
LUOGU P2986 [USACO10MAR]伟大的奶牛聚集Great Cow Gat…
查看>>
toad for oracle中文显示乱码
查看>>
scala的REPL shell的调用
查看>>
SQL中Group By的使用
查看>>
Mybatis映射原理,动态SQL,log4j
查看>>
哪个微信编辑器比较好用?
查看>>
错误org/aopalliance/intercept/MethodInterceptor解决方法
查看>>
Pylint在项目中的使用
查看>>
使用nginx做反向代理和负载均衡效果图
查看>>
access remote libvirtd
查看>>
gdb调试中出现No symbol table is loaded. Use the "file" command.问题
查看>>
(4) Orchard 开发之 Page 的信息存在哪?
查看>>
ASP.NET中 GridView(网格视图)的使用前台绑定
查看>>