抚琴煮酒
安装bind前先安装gcc,配置好yum源,yum -y install gcc,如果有run.pid报错,直接rm -rf /var/run/yum.pid (解决yum-updatesd服务正运行的情况)
下载 bind9.6到/root/Desktop,先进至目录里,然后wget ftp://ftp.isc.org/isc/bind9/9.6.0-P1/bind-9.6.0-P1.tar.gz
解压bind-9.6.0-P1.tar.gz
# tar zxvf bind-9.6.0-P1.tar.gz
进入 bind-9.6.0-P1tar.gz文件夹
# cd bind-9.5.0
创建安装目录,我是安装在 /usr/local/named
# mkdir /usr/local/named
编译,指定安装目录,指定man目录,开启多线程支持
# ./configure –prefix=/usr/local/named --mandir=/usr/local/share/man –enable-threads
#Make 大约需要几分钟,只要不报错就继续下去。
# make
#Make install 安装
# make install
没有报错,就表示安装成功了。
开始配置bind,接下来的过程是让rndc来管理bind9.6
创建 rndc.conf文件,用bind自带程序生成
进入/usr/local/named/etc,将rndc.conf及named.conf生成
# cd /usr/local/named/etc
# /usr/local/named/sbin/rndc-confgen > /usr/local/named/etc/rndc.conf
把rndc.conf 中的key信息输出到 named.conf 中
# tail –n10 rndc.conf | head -n9 | sed -e s/#\ //g > named.conf
这里强调一下,rndc.conf与named.conf的key值必须完全一样,而且并不需要生成rndc.key,这个问题纠缠了我大约3个小时
# vim named.conf
options {
Directory "/usr/local/named";
Pid-file "named.pid";
listen-on port 53 {any;};
Allow-query {any;};
Dump-file "/usr/local/named/data/cache_dump.db";
Statistics-file "/usr/local/named/data/named_stats.txt";
};
zone "." in {
Type hint;
File "named.root";
};
zone "localhost" in {
Type master;
File "localhost.zone";
};
zone "0.0.127.in-addr.arpa" in {
Type master;
File "localhost.rev";
};
zone "test.com" in {
Type slave;
masters { 192.168.1.254; };
File "slaves/test.com.zone";
};
zone "1.168.192.in-addr.arpa" in {
Type slave;
masters { 192.168.1.254; };
File "slaves/192.168.1.zone";
};
key "rndc-key" {
algorithm hmac-md5;
secret "OXV+irEfzfPRzteVYTqqCA==";
};
controls {
inet 127.0.0.1 port 953
allow { 127.0.0.1; } keys { "rndc-key"; };
};
顺便贴下我的从DNS的/usr/local/named/etc/named.conf文件
options {
Directory "/usr/local/named";
Pid-file "named.pid";
listen-on port 53 {any;};
Allow-query {any;};
Dump-file "/usr/local/named/data/cache_dump.db";
Statistics-file "/usr/local/named/data/named_stats.txt";
};
zone "." in {
Type hint;
File "named.root";
};
zone "localhost" in {
Type master;
File "localhost.zone";
};
zone "0.0.127.in-addr.arpa" in {
Type master;
File "localhost.rev";
};
zone "test.com" in {
Type slave;
masters { 192.168.1.254; };
File "slaves/test.com.zone";
};
zone "1.168.192.in-addr.arpa" in {
Type slave;
masters { 192.168.1.254; };
File "slaves/192.168.1.zone";
};
key "rndc-key" {
algorithm hmac-md5;
secret "OXV+irEfzfPRzteVYTqqCA==";
};
controls {
inet 127.0.0.1 port 953
allow { 127.0.0.1; } keys { "rndc-key"; };
};
写入以下内容
# vi localhost.zone
写入以下内容:
$TTL 3600
$ORIGIN 127.0.0.1.
@ IN SOA localhost. root.localhost. (
42 ;
3H ;
15M ;
1W ;
3600);
IN NS 127.0.0.1
IN A 127.0.0.1
创建并编辑 localhost.rev 文件
# vi localhost.rev
写入以下内容:
$TTL 3600
@ IN SOA localhost. root.localhost. (
1; serial
3600; refresh every hour
900; retry every 15 minutes
3600000; expire 1000 hours
3600); minimun 1 hour
IN NS localhost.
1 IN PTR localhost.
下载一个named.root cd /usr/local/named, 这个是named的工作目录
wget ftp://ftp.rs.internic.net/domain/named.root到/usr/local/named/下,
特别注意:bind的配置文档是区分大小写的。
下面就可以启动bind来测试安装是否成功了
# /usr/local/named/sbin/named –gc /usr/local/named/etc/named.conf &
加 –gc 参数,可以显示出启动日志,以便出错排查。
如果运行结果最后一行显示
Running
表明安装并启动成功。
测试rndc命令 /usr/local/named/sbin/rndc status,正确的话应该有状态提示,我一般是直接编辑vim /root/.bashrc加进一个alias rndc9='/usr/local/named/sbin/rndc'
把named 添加到启动项,随操作系统一起启动。
# cd /etc/rc.d
# vim rc.local
在最后添加以下内容
/usr/local/named/sbin/named –gc /usr/local/named/etc/named.conf &
退出保存。
可以尝试重启服务器,然后用命令nslookup及dig测试,或用pa axu | grep named,结束此服务用命令killall named,主从DNS也简单,适合更改下也可搞定这里可参照我其它文章,不多重复,全部安装结束,就可以开展应用的配置和测试了,抚琴煮酒为了保证正确率花了很多时间在真实服务器上,转载麻烦注明下,谢谢。