LINUX下BIND+VIEW实现双线智能解析(REHL5.4)
1、 软件列表
BIND 9.3.2
ftp://ftp.isc.org/isc/bind9/9.3.2/bind-9.3.2.tar.gz
ftp://ftp.isc.org/isc/bind9/9.4.0a6/bind-9.4.0a6.tar.gz
2、 安装BIND 9
安装BIND9:
# tar zxvf bind-9.3.2.tar.gz
# cd bind-9.3.2
# ./configure --prefix=/usr/local/named --disable-ipv6
# make && make install
建立BIND用户:
# groupadd bind
# useradd -g bind -d /usr/local/named -s /sbin/nologin bind
创建配置文件目录:
# mkdir –p /usr/local/named/etc
# chown bind:bind /usr/local/named/etc
# chmod 700 /usr/local/named/etc
二、named.conf的配置
创建主要的配置文件:
注视:一下ACL中的ip地址为联通的,也是最新的,这是我们数据中心专门做的!!!
# vi /usr/local/named/etc/named.conf
===========================named.conf=======================
acl "trust-lan" { any; };
options {
directory "/usr/local/named/etc/";
pid-file "/var/run/named/named.pid";
version "0.0.0";
auth-nxdomain no;
allow-query { any; };
allow-transfer { "trust-lan"; };
allow-notify { "trust-lan"; };
};
logging {
channel warning { file "/var/log/named/dns_warnings" versions 3 size 1240k;
severity warning;
print-category yes;
print-severity yes;
print-time yes;
};
channel general_dns
{ file "/var/log/named/dns_logs" versions 3 size 1240k;
severity info;
print-category yes;
print-severity yes;
print-time yes;
};
category default { warning; };
category queries { general_dns; };
};
acl "cnc" {
203.64.0.0/14;
203.66.0.0/14;
203.68.0.0/14;
110.16.0.0/14;
110.52.0.0/15;
110.6.0.0/15;
110.72.0.0/15;
112.109.128.0/17;
112.111.0.0/16;
112.122.0.0/15;
112.132.0.0/16;
112.192.0.0/14;
112.224.0.0/11;
112.64.0.0/15;
112.80.0.0/13;
112.88.0.0/13;
112.96.0.0/15;
113.0.0.0/13;
113.194.0.0/15;
113.200.0.0/15;
113.204.0.0/14;
113.224.0.0/12;
113.56.0.0/15;
113.58.0.0/16;
113.59.0.0/17;
113.8.0.0/15;
114.240.0.0/12;
115.46.0.0/16;
115.48.0.0/12;
115.85.192.0/18;
116.112.0.0/14;
116.116.0.0/15;
116.2.0.0/15;
116.95.0.0/16;
117.8.0.0/13;
118.212.0.0/16;
118.72.0.0/13;
118.80.0.0/15;
119.108.0.0/15;
119.112.0.0/13;
119.162.0.0/15;
119.164.0.0/14;
119.176.0.0/12;
119.248.0.0/14;
119.36.0.0/16;
119.39.0.0/16;
119.4.0.0/14;
119.48.0.0/13;
119.62.0.0/16;
120.0.0.0/12;
120.80.0.0/13;
121.16.0.0/13;
121.24.0.0/14;
121.28.0.0/15;
121.30.0.0/16;
121.31.0.0/16;
122.136.0.0/13;
122.156.0.0/14;
122.192.0.0/14;
122.96.0.0/15;
123.112.0.0/12;
123.128.0.0/13;
123.138.0.0/15;
123.144.0.0/14;
123.148.0.0/16;
123.152.0.0/13;
123.188.0.0/14;
123.232.0.0/14;
123.4.0.0/14;
123.8.0.0/13;
124.128.0.0/13;
124.160.0.0/16;
124.161.0.0/16;
124.162.0.0/16;
124.163.0.0/16;
124.164.0.0/14;
124.64.0.0/15;
124.66.0.0/17;
124.67.0.0/16;
124.88.0.0/16;
124.89.0.0/17;
124.89.128.0/17;
124.90.0.0/15;
124.92.0.0/14;
125.211.0.0/16;
125.32.0.0/16;
125.33.0.0/16;
125.34.0.0/16;
125.35.0.0/17;
125.35.128.0/17;
125.36.0.0/14;
125.40.0.0/13;
175.42.0.0/15;
202.102.128.0/21;
202.102.136.0/21;
202.102.144.0/20;
202.102.224.0/21;
202.102.232.0/21;
202.102.240.0/20;
202.106.0.0/16;
202.107.0.0/17;
202.108.0.0/16;
202.110.0.0/18;
202.110.192.0/18;
202.110.64.0/18;
202.111.128.0/19;
202.130.224.0/19;
202.38.143.0/24;
202.96.0.0/18;
202.96.64.0/21;
202.96.72.0/21;
202.96.80.0/20;
202.97.128.0/18;
202.97.192.0/19;
202.97.224.0/21;
202.97.232.0/21;
202.97.240.0/20;
202.98.0.0/21;
202.98.8.0/21;
202.99.0.0/18;
202.99.104.0/21;
202.99.112.0/20;
202.99.128.0/19;
202.99.160.0/21;
202.99.168.0/21;
202.99.176.0/20;
202.99.192.0/21;
202.99.200.0/21;
202.99.208.0/20;
202.99.224.0/21;
202.99.232.0/21;
202.99.240.0/20;
202.99.64.0/19;
202.99.96.0/21;
203.93.192.0/18;
203.93.64.0/18;
203.93.8.0/24;
203.196.0.0/16;
210.13.0.0/18;
210.13.128.0/17;
210.13.64.0/18;
210.14.160.0/19;
210.14.192.0/19;
210.15.128.0/18;
210.15.32.0/19;
210.15.96.0/19;
210.21.0.0/17;
210.51.0.0/16;
210.52.128.0/17;
210.53.0.0/17;
210.53.128.0/17;
210.74.128.0/19;
210.74.96.0/19;
210.78.0.0/19;
210.78.160.0/19;
210.78.192.0/18;
210.82.0.0/15;
211.144.0.0/15;
211.90.0.0/15;
211.92.0.0/15;
211.94.0.0/15;
211.96.0.0/15;
218.10.0.0/16;
218.104.0.0/17;
218.104.128.0/19;
218.104.160.0/19;
218.104.192.0/21;
218.104.200.0/21;
218.104.208.0/20;
218.104.224.0/19;
218.105.0.0/16;
218.106.0.0/15;
218.11.0.0/16;
218.12.0.0/16;
218.21.128.0/17;
218.24.0.0/15;
218.26.0.0/16;
218.27.0.0/16;
218.28.0.0/15;
218.56.0.0/14;
218.60.0.0/15;
218.67.128.0/17;
218.68.0.0/15;
218.7.0.0/16;
218.8.0.0/15;
218.240.0.0/16;
219.154.0.0/15;
219.156.0.0/15;
219.158.0.0/17;
219.158.128.0/17;
219.159.0.0/18;
220.192.0.0/15;
220.194.0.0/15;
220.196.0.0/14;
220.200.0.0/13;
220.248.0.0/14;
220.252.0.0/16;
221.0.0.0/15;
221.10.0.0/16;
221.11.0.0/17;
221.11.128.0/18;
221.11.192.0/19;
221.11.224.0/19;
221.12.0.0/17;
221.12.128.0/18;
221.13.0.0/18;
221.13.128.0/17;
221.13.64.0/19;
221.13.96.0/19;
221.14.0.0/15;
221.192.0.0/15;
221.194.0.0/16;
221.195.0.0/16;
221.196.0.0/15;
221.198.0.0/16;
221.199.0.0/19;
221.199.128.0/18;
221.199.192.0/20;
221.199.224.0/19;
221.199.32.0/20;
221.199.48.0/20;
221.199.64.0/18;
221.2.0.0/16;
221.200.0.0/14;
221.204.0.0/15;
221.206.0.0/16;
221.207.0.0/18;
221.207.128.0/17;
221.207.64.0/18;
221.208.0.0/14;
221.212.0.0/16;
221.213.0.0/16;
221.214.0.0/15;
221.216.0.0/13;
221.3.0.0/17;
221.3.128.0/17;
221.4.0.0/16;
221.5.0.0/17;
221.5.128.0/17;
221.6.0.0/16;
221.7.0.0/19;
221.7.128.0/17;
221.7.32.0/19;
221.7.64.0/19;
221.7.96.0/19;
221.8.0.0/15;
222.128.0.0/14;
222.132.0.0/14;
222.136.0.0/13;
222.160.0.0/15;
222.162.0.0/16;
222.163.0.0/19;
222.163.128.0/17;
222.163.32.0/19;
222.163.64.0/18;
58.144.0.0/16;
58.16.0.0/16;
58.17.0.0/17;
58.17.128.0/17;
58.18.0.0/16;
58.19.0.0/16;
58.20.0.0/16;
58.21.0.0/16;
58.22.0.0/15;
58.240.0.0/15;
58.242.0.0/15;
58.244.0.0/15;
58.246.0.0/15;
58.248.0.0/13;
60.0.0.0/13;
60.10.0.0/16;
60.11.0.0/16;
60.12.0.0/16;
60.13.0.0/18;
60.13.128.0/17;
60.13.64.0/18;
60.14.0.0/15;
60.16.0.0/13;
60.208.0.0/13;
60.216.0.0/15;
60.218.0.0/15;
60.220.0.0/14;
60.24.0.0/14;
60.28.0.0/15;
60.30.0.0/16;
60.31.0.0/16;
60.8.0.0/15;
61.133.0.0/17;
61.134.128.0/18;
61.134.192.0/18;
61.134.96.0/19;
61.135.0.0/16;
61.136.0.0/18;
61.136.64.0/18;
61.137.128.0/17;
61.138.0.0/18;
61.138.128.0/18;
61.138.64.0/18;
61.139.128.0/18;
61.148.0.0/15;
61.156.0.0/16;
61.158.0.0/17;
61.158.128.0/17;
61.159.0.0/18;
61.161.0.0/18;
61.161.128.0/17;
61.162.0.0/16;
61.163.0.0/16;
61.167.0.0/16;
61.168.0.0/16;
61.176.0.0/16;
61.179.0.0/16;
61.180.128.0/17;
61.181.0.0/16;
61.182.0.0/16;
61.189.0.0/17;
61.240.0.0/14;
61.48.0.0/14;
61.52.0.0/15;
61.54.0.0/16;
61.55.0.0/16;
};
view "view_cnc" {
match-clients { cnc; };
zone "." {
type hint;
file "named.root";
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "0.0.127.IN-ADDR.ARPA" {
type master;
file "localhost.rev";
};
include "master/cnc.def";
};
view "view_any" {
match-clients { any; };
zone "." {
type hint;
file "named.root";
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "0.0.127.IN-ADDR.ARPA" {
type master;
file "localhost.rev";
};
include "master/telecom.def";
};
key "rndc-key" {
algorithm hmac-md5;
secret "29qJ0YZ+7GB5AS8GJEmpoQ==";
};
controls {
inet 127.0.0.1 port 953
allow { 127.0.0.1; } keys { "rndc-key"; };
};添加完成后,保存。
三、更新根区文件:
# cd /usr/local/named/etc/
# wget ftp://ftp.internic.org/domain/named.root
注意:你的环境,你必须可以访问互联网,并且配置了DNS,可以访问ftp://ftp.internic.org/domain/named.root,才可以跟新跟区域文件!!!
创建PID和日志文件:
# mkdir /var/run/named/
# chmod 777 /var/run/named/
# chown bind:bind /var/run/named/
# mkdir /var/log/named/
# touch /var/log/named/dns_warnings
# touch /var/log/named/dns_logs
# chown bind:bind /var/log/named/*
# mkdir master
# touch master/cnc.def
# touch master/telecom.def
生成rndc-key:
# cd /usr/local/named/etc/
# ../sbin/rndc-confgen > rndc.conf
把rndc.conf中:
# Use with the following in named.conf, adjusting the allow list as needed:
后面的部分添加到/usr/local/named/etc/named.conf中并去掉注释(这是认证,要保持named.conf中的KEY和rndc.conf中KEY保持一致)
运行测试:
# /usr/local/named/sbin/named -gc /usr/local/named/etc/named.conf &
测试后如果提示:缺少localhost.zone和localhost.rev,那就在/usr/local/named/etc/下创建
状态检查:
# /usr/local/named/sbin/rndc status
五、添加一个NS
在域名的管理网站上,设定NS服务器为你安装的DNS服务器
六、添加一个域名
# cd /usr/local/named/etc/master
# mkdir cnc
# mkdir telecom
# vi cnc.def
添加
zone "test.com" {
type master;
file "master/cnc/test.com";
};
# vi telecom.def
添加
zone "test.com" {
type master;
file "master/telecom/test.com";
};
然后添联通的解析#vi cnc/test.com
添加
$TTL 3600
$ORIGIN test.com.
@ IN SOA ns.test.com. root.ns.test.com.(
2005121013 ;Serial
3600 ; Refresh ( seconds )
900 ; Retry ( seconds )
68400 ; Expire ( seconds )
15 );Minimum TTL for Zone ( seconds )
;
@ IN NS ns.test.com.
@ IN A 211.162.106.9
www IN A 211.162.106.9
;
;end
添加电信的解析#vi telecom/724cn.com
添加
$TTL 3600
$ORIGIN test.com.
@ IN SOA ns.test.com. root.ns.test.com.(
2005121013 ;Serial
3600 ; Refresh ( seconds )
900 ; Retry ( seconds )
68400 ; Expire ( seconds )
15 );Minimum TTL for Zone ( seconds )
;
@ IN NS ns.test.com.
@ IN A 211.162.106.254
www IN A 211.162.106.254
;
;end
#/usr/local/named/sbin/rndc reload
#/usr/local/named/sbin/rndc reload(加载DNS服务)
至此,你的智能DNS服务器已经跑起来了!!!