bind-9.5.0-P2.tar.gz
1 解压
tar zxvf bind-9.5.0-P2.tar.gz -C /usr/local/src
2 进入目录
cd /usr/local/src/bind-9.5.0-P2
3 配置
# ./configure --prefix=/usr/local/named --enable-threads --disable-openssl-version-check
--enable-threads 开启多线程支持
--disable-openssl-version-check 关闭openssl,要不就把opensll装上
5 编译和安装
# make ; make install
6 看一看版本现版本是多少
# /usr/local/named/sbin/named -v
7 生成rndc控制命令的key文件。
bind9 规定,如果要使用rndc 来控制dns 。必须先生成验证文件.rndc.conf 和密锁.
# /usr/local/named/sbin/rndc-confgen > /usr/local/named/etc/rndc.conf(生成这个文件按 你--prefix 而定)
8 建立区域文件目录 /usr/local/named/var/named
#mkdir named
9 从rndc.conf文件中提取named.conf用的key (根据自己需求改变路径)
#tail -10 rndc.conf | head -9 | sed s/#\ //g >named.conf
这个命令就是把rndc.conf里的一段复制到named.conf里
# Use with the following in named.conf, adjusting the allow list as needed:
key "rndc-key" {
algorithm hmac-md5;
secret "5hhmFj6S3Pn6EoDnOvlblg==";
};
controls {
inet 127.0.0.1 port 953
allow { 127.0.0.1; } keys { "rndc-key"; };
};
# End of named.conf
10 编辑配置文件named.conf、区域文件
# 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:到/usr/local/named/下,
特别注意:bind的配置文档是区分大小写的。
下面就可以启动bind来测试安装是否成功了
11 启动服务
# /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
# vi rc.local
在最后添加以下内容
/usr/local/named/sbin/named –gc /usr/local/named/etc/named.conf &
退出保存。
可以尝试重启服务器,然后telnet 服务器IP地址的53端口,验证bind是否启动。
# shutdown –r now
# telnet x.x.x.x 53
全部安装结束,就可以开展应用的配置和测试了
vim /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -p udp -m udp --dport 53 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 53 -j ACCEPT
/etc/init.d/iptables restart
=================================================
807 tar zxvf bind-9.5.0.tar.gz
808 cd bind-9.5.0
839 ./configure --prefix=/usr/local/bind9.5 --enable-threads --sysconfdir=/etc --sysconfdir=/var --with-libxml2=/usr/include/libxml2 --disable-openssl-version-check
840 make clean
842 make diskclean
843 ./configure --prefix=/usr/local/bind9.5 --enable-threads --sysconfdir=/etc --sysconfdir=/var --with-libxml2=/usr/include/libxml2 --disable-openssl-version-check
844 make
845 make install
847 /usr/local/bind9.5/sbin/named -v
854 cd /usr/local/bind9.5
858 mkdir etc
870 cd etc
872 vim rndc.conf
874 vim /etc/rndc.conf
876 mkdir -p /var/named
878 tail -10 rndc.conf | head -9 | sed s/#\ //g >named.conf
879 tail -10 rndc.conf | head -9 | sed s/#\ //g >/etc/named.conf
880 vim /etc/rndc.conf
881 vim named.conf
882 tail -10 rndc.conf | head -9 | sed s/#\ //g > /etc/named.conf
883 vim /etc/rndc.conf
884 cd /etc
885 tail -10 rndc.conf | head -9 | sed s/#\ //g > /etc/named.conf
886 tail -10 rndc.conf | head -9 | sed s/#\ //g > named.conf
906 /usr/local/bind9.5/sbin/named -gc /etc/named.conf &
907 /usr/local/bind9.5/sbin/rndc status
910 rndc reload
912 /usr/local/bind9.5/sbin/rndc reload
917 ln -s /etc/rndc.conf /var/rndc.conf