1、下载bind-9.9.7rc1.tar.gz
https://www.isc.org/downloads/
2、解压tar zxvf bind-9.9.7rc1.tar.gz
cd bind-9.9.7rc1
3、编译安装
./configure --prefix=/usr/local/named --enable-threads #--enable-threads
提示没有openssl
checking for OpenSSL library... configure: error: OpenSSL was not found in any of /usr /usr/local /usr/local/ssl /usr/pkg /usr/sfw; use --with-openssl=/path
--------------------------------------------------------------------------------------------------
提示没有OpenSSL
解决方案:
yum install openssl
yum install openssl-devel
【 ubuntu系统解决方案 apt-get install openssl apt-get install libssl-dev】
【sudo ./rndc-confgen > rndc.conf 反应很久】
----------------------------
解决方案:
http://www.nginxs.com/linux/43.html
【/home/wkubuntu/named/sbin/named -c /home/wkubuntu/named/etc/named.conf & 按两次,没有出现 done 】
---------------------------
cd /home/wkubuntu/named/etc
vi named.conf 修改一下这个文件。。把上面copyright 去掉
-----------------------------------------------------------------------------------------------------------------------------------------------
2015年2月4日
1、sudo wget ftp://ftp.isc.org/isc/bind9/9.10.1/bind-9.10.1.tar.gz
2、tar -zxvf bind-9.10.1.tar.gz
3、创建目录
在/home/wkubuntu下创建named目录和namedfile目录
4、编译安装
cd bind-9.10.1
./configure --prefix=/home/wkubuntu/named/ --with-dlz-mysql=/usr/local/mysql
make
make install
此时进入/home/wkubuntu/named目录,里面自动生成了bin etc include lib sbin share var这些文件目录
5、配置bind
cd /home/wkubuntu/named/etc
touch named.conf
vi named.conf张贴内容1
在/home/wkubuntu/named/var 目录下拷贝那5个文件
生成rndc的key
a)cd /home/wkubuntu/named/sbin/
b)vim random 输入很长一段字母。就是服务器上没有random产生器,这种情况下我们就手动伪造一个文件代替/dev/random的功能
c)rndc-confgen -r random > /etc/rndc.key
d)cat /etc/rndc.key
e)拷贝
secret "pfNOQ0fENSBBGBYn/ndRsw=="; 这一行
覆盖/home/wkubuntu/named/etc 的named.conf对应的那一行
6、启动bind ,打印进程
输入两次sudo /home/wkubuntu/named/sbin/named -c /home/wkubuntu/named/etc/named.conf &
出现done 就代表成功了
【如果出现了exit,出错了,看打印进程sudo /home/wkubuntu/named/sbin/named -gc /home/wkubuntu/named/etc/named.conf &
killall named 可以关闭掉所有named,如果用了-gc的话】
要建立一个log目录,如下的配置 mkdir logs
/home/wkubuntu/named/logs
其他:
内容1:
logging{ channel error_log { file "/home/wkubuntu/named/logs/normal.log" versions 3 size 2m; severity error; print-time yes; print-severity yes; print-category yes; }; category default{ error_log; }; channel update_log{ file "/home/wkubuntu/named/logs/update.log" versions 3 size 1m; severity info; print-time yes; print-severity yes; print-category yes; }; category update{ update_log; }; channel notify_log{ file "/home/wkubuntu/named/logs/notify.log" versions 3 size 1m; severity info; print-time yes; print-severity yes; print-category yes; }; category notify{ notify_log; }; }; options { directory "/home/wkubuntu/named/var/"; pid-file "/home/wkubuntu/named/var/run/named/named.pid"; dump-file "/home/wkubuntu/named/logs/named_dump.db"; statistics-file "/home/wkubuntu/named/logs/named.stats"; version "Welcome to NIOT platform!"; listen-on-v6 { any; }; allow-query { any; }; allow-query-cache { any; }; allow-recursion { localnets; localhost; }; notify no; }; key "rndc-key" { algorithm hmac-md5; secret "fLDVvLVXFjMJpdiy+7nESw=="; }; controls { inet 127.0.0.1 port 953 allow { 127.0.0.1; } keys { "rndc-key"; }; }; zone "." IN { type hint; file "/home/wkubuntu/named/var/named.root"; }; zone "localhost" IN { type master; file "/home/wkubuntu/named/var/localhost.zone"; allow-update { none; }; }; zone "0.0.127.in-addr.arpa" IN { type master; file "/home/wkubuntu/named/var/localhost.reverse"; allow-update { none; }; }; dlz "Mysql zone" { database "mysql {host=127.0.0.1 dbname=db_epp 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) when lower(type) = ‘naptr‘ then concat(‘ ‘, naptr_order, ‘ ‘, naptr_preference, ‘ \"‘, naptr_flags, ‘\"‘, ‘ \"‘, naptr_service, ‘\"‘, ‘ \"‘, naptr_regexp,‘\" ‘, data, ‘.‘) else data end from dns_records where zone = ‘$zone$‘ and host = ‘$record$‘}"; };
7、测试
dig @localhost 6920000000012.running.niot.cn naptr
数据库里面要有这条记录,如上测试即可