经过两天的编译,终于OK了,再在打过程写来了,
安装mysql数据库,这里我就不多说了,
再到下载mysql-bind.tar-gz
tar -zxvf bind-9.4.2.tar.gz
tar -zxvf mysql-bind.tar.gz
cp mysql-bind/* bind-9.4.2/bin/named -f
mysql-bind/* bind-9.4.2/bin/named/include -f
mysql-bind/* bind-9.4.2/bin/named/include/named -f
要bind支持SDB,,还要修改两个文件在bind-9.4.2/bin/named下的main.c及Makefile.in
main.c在683行加入一句mysqldb_init();如下
/*
* Add calls to register sdb drivers here.
*/
/* xxdb_init(); */
mysqldb_init();
在710行加入一句mysqldb_clear();如下
/*
* Add calls to unregister sdb drivers here.
*/
/* xxdb_clear(); */
mysqldb_clear();
再修改Makefile.in,,将29-32改成如下
DBDRIVER_OBJS = @
DBDRIVER_SRCS = mysqldb.c
DBDRIVER_INCLUDES = -I'/usr/local/mysql/include/mysql'
DBDRIVER_LIBS = -L'/usr/local/mysql/lib/mysql' -lmysqlclient -lz -lcrypt -lnsl -lm -lc -lnss_files -lnss_dns -lresolv -lc -lnss_files -lnss_dns -lresolv
如果大家找到不行号,在用vi编辑的时候,可以设置行号:set nu
编译安装:
cd bind-9.4.2
./configure --prefix=/usr/local/sdb2
make;make install
接下来的就是数据库和配置文件了,我们先建库吧!
引用原文件:
* Example SQL to create a domain
* ==============================
*
* CREATE TABLE mydomain (
* name varchar(255) default NULL,
* ttl int(11) default NULL,
* rdtype varchar(255) default NULL,
* rdata varchar(255) default NULL
* ) TYPE=MyISAM;
*
* INSERT INTO mydomain VALUES ('mydomain.com', 259200, 'SOA', 'mydomain.com. . 200309181 28800 7200 86400 28800');
* INSERT INTO mydomain VALUES ('mydomain.com', 259200, 'NS', 'ns0.mydomain.com.');
* INSERT INTO mydomain VALUES ('mydomain.com', 259200, 'NS', 'ns1.mydomain.com.');
* INSERT INTO mydomain VALUES ('mydomain.com', 259200, 'MX', '10 mail.mydomain.com.');
* INSERT INTO mydomain VALUES ('w0.mydomain.com', 259200, 'A', '192.168.1.1');
* INSERT INTO mydomain VALUES ('w1.mydomain.com', 259200, 'A', '192.168.1.2');
* INSERT INTO mydomain VALUES ('mydomain.com', 259200, 'Cname', 'w0.mydomain.com.');
* INSERT INTO mydomain VALUES ('mail.mydomain.com', 259200, 'Cname', 'w0.mydomain.com.');
* INSERT INTO mydomain VALUES ('ns0.mydomain.com', 259200, 'Cname', 'w0.mydomain.com.');
* INSERT INTO mydomain VALUES ('ns1.mydomain.com', 259200, 'Cname', 'w1.mydomain.com.');
* INSERT INTO mydomain VALUES ('', 259200, 'Cname', 'w0.mydomain.com.');
* INSERT INTO mydomain VALUES ('ftp.mydomain.com', 259200, 'Cname', 'w0.mydomain.com.');
这里我就不多说了,这个应该很简单的,不过要说明的是,我们要建两个一样的库,因为是做VIEW,,所以必须建两个, 我建的两个库分别为ecdncnc和ecdntel,,我做的是双线,大家可以做再多的,你想要多少就成!
配置conf文件如下:
cd /usr/local/bind-dlz/sbin
./rndc-confgen -a
./rndc-confgen >../etc/rndc.conf
cd ..;cd etc
dig >named.root
tail -10 rndc.conf |head -9 |sed s/#\ //g >named.conf
named.conf内容如下:
[root@localhost etc]# cat named.conf
key "rndc-key" {
algorithm hmac-md5;
secret "HDVBwMHNNYZcozWB0dIAjw==";
};
controls {
inet 127.0.0.1 port 953
allow { 127.0.0.1; } keys { "rndc-key"; };
};
include "ip.conf";
view "view_cnc" {
match-clients { CNC; };
zone "." {
type hint;
file "named.root";
};
zone "0.0.127.IN-ADDR.ARPA" IN {
type master;
file "localhost.rev";
};
zone "easy-cdn.cn" IN {
type master;
notify no;
database "mysqldb sdbview ecdncnc localhost akin akin";
};
};
view "view_any" {
match-clients { any; };
zone "." {
type hint;
file "named.root";
};
zone "0.0.127.IN-ADDR.ARPA" IN {
type master;
file "localhost.rev";
};
zone "easy-cdn.cn" IN {
type master;
notify no;
database "mysqldb sdbview ecdntel localhost akin akin";
};
};
named.conf的配置就完成了,还有一个文件,是ip.conf,安的内容如下:
[root@localhost etc]# cat ip.conf
acl CNC{
192.168.1.1/24;
};
这个就是IP段,大家可以写真实的,因为是测试,就写简单的了,这里可以加很多,比如电信,网通,教育之类的,都呆以写在这里,只要在ZONE里加新内容,就可以成为多线智能DNS,以上的配置文件为两线的!
再运行,,完成
[root@localhost sbin]# ./named -g
22-Mar-2008 14:26:06.648 starting BIND 9.4.2 -g
22-Mar-2008 14:26:06.656 loading configuration from '/usr/local/sdb2/etc/named.conf'
22-Mar-2008 14:26:06.661 listening on IPv4 interface lo, 127.0.0.1#53
22-Mar-2008 14:26:06.667 listening on IPv4 interface eth0, 192.168.1.241#53
22-Mar-2008 14:26:06.691 automatic empty zone: view view_cnc: 127.IN-ADDR.ARPA
22-Mar-2008 14:26:06.692 automatic empty zone: view view_cnc: 254.169.IN-ADDR.ARPA
22-Mar-2008 14:26:06.693 automatic empty zone: view view_cnc: 2.0.192.IN-ADDR.ARPA
22-Mar-2008 14:26:06.694 automatic empty zone: view view_cnc: 255.255.255.255.IN-ADDR.ARPA
22-Mar-2008 14:26:06.695 automatic empty zone: view view_cnc: 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.ARPA
22-Mar-2008 14:26:06.696 automatic empty zone: view view_cnc: 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.ARPA
22-Mar-2008 14:26:06.697 automatic empty zone: view view_cnc: D.F.IP6.ARPA
22-Mar-2008 14:26:06.698 automatic empty zone: view view_cnc: 8.E.F.IP6.ARPA
22-Mar-2008 14:26:06.698 automatic empty zone: view view_cnc: 9.E.F.IP6.ARPA
22-Mar-2008 14:26:06.700 automatic empty zone: view view_cnc: A.E.F.IP6.ARPA
22-Mar-2008 14:26:06.700 automatic empty zone: view view_cnc: B.E.F.IP6.ARPA
22-Mar-2008 14:26:06.721 automatic empty zone: view view_any: 127.IN-ADDR.ARPA
22-Mar-2008 14:26:06.722 automatic empty zone: view view_any: 254.169.IN-ADDR.ARPA
22-Mar-2008 14:26:06.723 automatic empty zone: view view_any: 2.0.192.IN-ADDR.ARPA
22-Mar-2008 14:26:06.723 automatic empty zone: view view_any: 255.255.255.255.IN-ADDR.ARPA
22-Mar-2008 14:26:06.724 automatic empty zone: view view_any: 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.ARPA
22-Mar-2008 14:26:06.725 automatic empty zone: view view_any: 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.ARPA
22-Mar-2008 14:26:06.726 automatic empty zone: view view_any: D.F.IP6.ARPA
22-Mar-2008 14:26:06.727 automatic empty zone: view view_any: 8.E.F.IP6.ARPA
22-Mar-2008 14:26:06.728 automatic empty zone: view view_any: 9.E.F.IP6.ARPA
22-Mar-2008 14:26:06.728 automatic empty zone: view view_any: A.E.F.IP6.ARPA
22-Mar-2008 14:26:06.730 automatic empty zone: view view_any: B.E.F.IP6.ARPA
22-Mar-2008 14:26:06.748 command channel listening on 127.0.0.1#953
22-Mar-2008 14:26:06.749 ignoring config file logging statement due to -g option
22-Mar-2008 14:26:06.755 zone 0.0.127.IN-ADDR.ARPA/IN/view_cnc: loaded serial 1997022700
22-Mar-2008 14:26:06.781 zone 0.0.127.IN-ADDR.ARPA/IN/view_any: loaded serial 1997022700
22-Mar-2008 14:26:06.794 running
注意的事,在数据库加入SOA和NS上,在域名的后面有点,可以看引用原文的那段,昨天就是因为没加点,所以NSLOOKUP老不反回数据,现在已经OK了
接下来就是编写web管理界面了,应该很简单,就是一些数据删除,插入,更新,应该很快就写好,这个会加入到Easy-CDN里面去,把管理界面都整合了!!!
阅读(2138) | 评论(0) | 转发(0) |