cow_boys 发表于 2011-2-24 09:27:29

用Bind源码构建企业Dns缓存服务器

用Bind源码构建企业Dns缓存服务器。

安装Bind

#tar –zxvf bind-9.2.1.tar.gz
#cd bind-9.2.1
#./configure
#make
#make install

这种编译源码的安装方式是不会自动创建named.conf和工作目录的,要手工创建。

#mkdir /var/named

运行/usr/local/sbin/rndc-confgen获得rndc-key,利用生成的信息建立/etc/rndc.conf
内容如下:
# Start of rndc.conf
key "rndc-key" {
      algorithm hmac-md5;
      secret "t+QqnfoI33qrpXZR/EvIYw==";
};

options {
      default-key "rndc-key";
      default-server 127.0.0.1;
      default-port 953;
};
# End of rndc.conf

# Use with the following in named.conf, adjusting the allow list as needed:
# key "rndc-key" {
#       algorithm hmac-md5;
#       secret "t+QqnfoI33qrpXZR/EvIYw==";
# };
#
# controls {
#       inet 127.0.0.1 port 953
#               allow { 127.0.0.1; } keys { "rndc-key"; };
# };
# End of named.conf

建立Bind的主配置文件/etc/named.conf
内容如下:
options {
      directory "/var/named";
      forwarders { 202.96.134.133;202.96.128.68; };
};
zone "." IN {
      type hint;
      file "named.root";
};
key "rndc-key" {
      algorithm hmac-md5;
      secret "t+QqnfoI33qrpXZR/EvIYw==";
};
controls {
      inet 127.0.0.1 port 953
      allow { 127.0.0.1; } keys { "rndc-key"; };
};

建立/var/named/named.root文件,它包含了根服务器的IP地址。由于该文件是一个不断更新的文件,建议读者从Internet上下载一个最新的版本.其内容如下所示:
3600000 IN NS A.ROOT-SERVERS.NET.
A.ROOT-SERVERS.NET. 3600000 A 198.41.0.4
3600000 NS B.ROOT-SERVERS.NET.
B.ROOT-SERVERS.NET. 3600000 A 128.9.0.107
3600000 NS C.ROOT-SERVERS.NET.
C.ROOT-SERVERS.NET. 3600000 A 192.33.4.12
3600000 NS D.ROOT-SERVERS.NET.
D.ROOT-SERVERS.NET. 3600000 A 128.8.10.90
3600000 NS E.ROOT-SERVERS.NET.
E.ROOT-SERVERS.NET. 3600000 A 192.203.230.10
3600000 NS F.ROOT-SERVERS.NET.
F.ROOT-SERVERS.NET. 3600000 A 192.5.5.241
3600000 NS G.ROOT-SERVERS.NET.
G.ROOT-SERVERS.NET. 3600000 A 192.112.36.4
3600000 NS H.ROOT-SERVERS.NET.
H.ROOT-SERVERS.NET. 3600000 A 128.63.2.53
3600000 NS I.ROOT-SERVERS.NET.
I.ROOT-SERVERS.NET. 3600000 A 192.36.148.17
3600000 NS J.ROOT-SERVERS.NET.
J.ROOT-SERVERS.NET. 3600000 A 198.41.0.10
3600000 NS K.ROOT-SERVERS.NET.
K.ROOT-SERVERS.NET. 3600000 A 193.0.14.129
3600000 NS L.ROOT-SERVERS.NET.
L.ROOT-SERVERS.NET. 3600000 A 198.32.64.12
3600000 NS M.ROOT-SERVERS.NET.
M.ROOT-SERVERS.NET. 3600000 A 202.12.27.33

到些,bind已经可以工作了.修改/etc/rc.d/rc.local
增加一行.
/usr/sbin/named

重启一下.linux 
reboot
这样就可以把内网的dns指向安装有bind这台机器了.

txwwy 发表于 2011-2-24 12:47:28

国内应为主流网站的都做了CDN,所以还是不要用 bind 做权威服务器,建议还是配置成为缓存服务器,访问网站速度要快一些,bind上配置DNS 还是用你主ISP 的DNS


vi /usr/local/bind9/etc/named.conf
options {
         forward only;            
         forwarders {
               202.97.224.68;                  
               202.97.224.79;        
         };
};

wld2005 发表于 2013-12-20 09:41:53

这个真心不懂 ,求详细教程

jike106397 发表于 2013-12-20 19:53:55

wld2005 发表于 2013-12-20 09:41
这个真心不懂 ,求详细教程

http://bbs.routerclub.com/thread-70890-1-1.html

我这个也可以做个参考,主要应该自己配置一遍.
页: [1]
查看完整版本: 用Bind源码构建企业Dns缓存服务器