bind + mysq配置

 

a.安装mysql5.0
#./configure --prefix=/usr/local/mysql
#make&&make install
   b.改变mysql目录属性
   c.产生mysql数据库授权表
   d.启动数据库并更改root密码
2. a.安装bind9.5
# ./configure --prefix=/usr/local/bind9 --with-dlz-mysql=/usr/local/mysql
# make&&make install 
b.设置脚本
设置bind工作目录 echo 'options {directory "/usr/local/bind";};' > named.conf
生成key ../sbin/rndc-confgen >rndc.conf 
tail -n10 rndc.conf | head -n9 | sed -e s/#\//g >>named.conf
 导入最新DNS根域名  dig > named.root
C.建立view视图
 #vi view.conf
 内容:
view "test_view" {
 
 match-clients           { any; };
 allow-query-cache       { any; };
 allow-recursion         { none; };
 allow-transfer          { none; };
 recursion               yes;
 
   dlz "Mysql zone" {
   database "mysql
   {host=localhost dbname=dnsdata ssl=false port=3306 user=root pass=35com }
   {select zone from dns_records where zone = '%zone%' and view='TEL' 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='TEL'}
   {}
   {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='TEL'}";
   };
};
 
Echo “include "/usr/local/bind9/etc/view.conf">>named.conf
3.a.建立数据库并导入数据
Mysql>create database dnsdata
Mysql>use dnsdata
Mysql> 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('TEL','ANY') NOT NULL,
  `mx_priority` int(11) DEFAULT NULL,
  `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 '2009122300',
  `resp_person` varchar(64) NOT NULL DEFAULT 'wdlinux.cn',
  `primary_ns` varchar(64) NOT NULL DEFAULT 'ns1.wdlinux.cn.',
  `second_ns` varchar(64) NOT NULL DEFAULT 'ns2.wdlinux.cn.',
  `data_count` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `type` (`type`),
  KEY `host` (`host`),
  KEY `zone` (`zone`)
) ENGINE=MyISAM AUTO_INCREMENT=214 DEFAULT CHARSET=gbk;
 
Mysql>insert into dns_records (zone,host,type,data,ttl,view,retry) values ('aa2000.com','www','A','192.168.16.235','86400','ANY','28800');
4 启动bind服务
/usr/local/bind9/sbin/named -gc  /usr/local/bind9/etc/named.conf
5检查解析否成功
 
 
 
 
-----------------------------------------------------
文本模式
 
name.com
 
$TTL 86400
@  IN  SOA localhost.  [email protected]. (
2 ; serial
28800 ;  refresh
7200 ;  retry
604800 ;  expire
86400 ;  Minimum
)
@  IN  NS   localhost.
www.aaa123        IN  A 192.168.16.235
 
 
name.16.168.192
 
$TTL 86400
@  IN  SOA ns.test.com.  [email protected]. (
2 ; serial
28800 ;  refresh
7200 ;  retry
604800 ;  expire
86400 ;  Minimum
)
@   IN     NS  ns.test.com.
192.168.16.235  IN PTR www.aaa123.com.
 
name.conf
 
 
 
 
options {
directory "/usr/local/bind9/etc"; // Working directory
dump-file "/usr/local/bind9/cache_dump.db";
forward First;
forwarders { 10.35.0.3; };
};
 key "rndc-key" {
        algorithm hmac-md5;
        secret "yMJ1O48DkxqeEJWAGZL+Tw==";
 };
 
 controls {
        inet 127.0.0.1 port 953
                allow { 127.0.0.1; } keys { "rndc-key"; };
 };
zone "." IN {
type hint;
file "named.root";
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
};
zone "com" IN {
type master;
file "named.com";
};
zone "16.168.192.in-addr.arpa" IN {
type master;
file "named.16.168.192";
};
 
 
 
 
 
 
 
 
 
 
 

你可能感兴趣的:(职场,bind,mysq,休闲)