經過兩天的編譯,終於OK了,再把過程寫來了,
安裝mysql資料庫,這裡我就不多說了,
再到http://mysql-bind.sourceforge.net/下載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 = mysqldb.@O@
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. www.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 ('www.mydomain.com', 259200, 'Cname', 'w0.mydomain.com.');
* INSERT INTO mydomain VALUES ('ftp.mydomain.com', 259200, 'Cname', 'w0.mydomain.com.');
這裡我就不多說了,這個應該很簡單的,不過要說明的是,我們要建兩個一樣的庫,因為是做VIEW,,所以必須建兩個, 我建的兩個庫分別為ecdncnc和ecdntel,,我做的是雙線,大家可以做更多些,你想要多少就成!
配置conf文件如下:
cd /usr/local/sdb2
./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內容如下:
# 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,安的內容如下:
# cat ip.conf
acl CNC{
192.168.1.1/24;
};
這個就是IP段,大家可以寫真實的,因為是測試,就寫簡單的了,這裡可以加很多,比如電信,網通,教育之類的,都呆以寫在這裡,只要在ZONE里加新內容,就可以成為多線智能DNS,以上的配置文件為兩線的!
再運行,,完成
# ./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了
[火星人 ] bind-9.4.2+mysql+sdb+view安裝已經有1005次圍觀