ttl 86400
@ IN SOA localhost. root.localhost. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS localhost.
1 IN PTR localhost.
dig >named.root
再named.conf加入以下内容:
[root@localhost etc]# cat named.conf
options {
version "akindns-ICP";
recursion no;
};
key "rndc-key" {
algorithm hmac-md5;
secret "cEPUadafJTtnG0Moxdhz+w==";
};
controls {
inet 127.0.0.1 port 953
allow { 127.0.0.1; } keys { "rndc-key"; };
};
dlz "Mysql zone" {
database "mysql
{host=127.0.0.1 dbname=nn_dns_data ssl=false port=3306 user=root pass=root }
{select zone from dns_records where zone = '%zone%' 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%'}
{}
{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%'}
{select zone from xfr_table where zone = '%zone%' and client = '%client%' limit 1}
{update data_count set count = count + 1 where zone ='%zone%'}";
};
#include "/usr/local/bind-dlz/etc/rndc.key";
[root@localhost etc]#
再建一个数据库nn_dns_data,建一个表dns_records
CREATE DATABASE nn_dns_data;
use nn_dns_data;
CREATE TABLE 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(20),
resp_person varchar (255),
primary_ns varchar (255)
);
加入一条记录
INSERT INTO `dns_records` ( `zone` , `host` , `type` , `data` , `ttl` , `mx_priority`
, `refresh` , `retry` , `expire` , `minimum` , `serial` , `resp_person` , `primary_ns` ) VALUES ( 'hibelle.cn', '*', 'A', '192.168.1.1', '800', NULL , NULL , '10', NULL ,
NULL , NULL , NULL , NULL );
./named -u root -g -d 1
结果少了,libmysqlclient.so.15,,查找到在MYSQL的目录,将它复制到/USR/LIB就OK了
cp /usr/local/mysql/lib/mysql/libmysqlclient.so.15 /usr/lib/
这样就OK了,再运行
/usr/local/bind-dlz/sbin/named -u root -g -d 1
完成,再试一下,再运NSLOOKUP
[root@localhost ~]# nslookup
> server 127.0.0.1
Default server: 127.0.0.1
Address: 127.0.0.1#53
>
Server: 127.0.0.1
Address: 127.0.0.1#53
Name:
Address: 192.168.1.1
> alsdkfj.hibelle.cn
Server: 127.0.0.1
Address: 127.0.0.1#53
Name: alsdkfj.hibelle.cn
Address: 192.168.1.1
> sasdfasfasf.hibelle.cn
Server: 127.0.0.1
Address: 127.0.0.1#53
Name: sasdfasfasf.hibelle.cn
Address: 192.168.1.1
>
完成,,后两个我随便写的,都能解释到192.168.1.1,因为那个加入的数据,是泛解释的,所以。。。。。
搞定!
接下来。再摘定VIEW,,!