BIND智能解析域名

BIND智能解析域名
 
要求,用同一个域名访问,解决电信网通访问速度问题?
 安装BIND9
 1.下载: https://www.isc.org/
 2.解压编译。
 3.编译配置:./configure --enable-threads --disable-openssl-version-check
 4.编译:make
 5.安装:make install
 6.安装清理:make clean

一、域名解析如下:
1.域名:www.0002.cn www.test.com
2.www.0002.cn A记录解析到 219.153.49.240 DNS服务器
3.在域名注册商注册一个NS.0002.CN的域名解析地址 指向 IP:219.153.49.240
4.修改 www.0002.cn 的NS解析地址 为NS.0002.CN
5.把 www.test.com 域名的CNAME记录指向 www.test.com.0002.cn
6.NS服务器IP 219.153.49.240 安装BIND9
二、DNS服务器具体配置如下:
配置文件主要有以下几个
cnc.conf               # 网通IP库
named.root          # 根DNS解析地址
named.conf         #DNS主配置文件
test.tel.zone       #正向电信解析文件
test.tel.rev          #反向电信解析文件
test.cnc.zone     #正向网通解析文件
test.cnc.rev        #反向网通解析文件
localhost.zone    #正向本地解析文件
localhost.rev      #反向本地解析文件
=====================================================
cnc.conf  文件内容
###################### cnc.conf############################
# 3/12/2008 09:44:25 by fish
# software id = EFTB-IZN
#
acl "CNC" {
219.153.49.245;
218.201.40.0/22;
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.8.0.0/15;
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.14.0.0/15;
60.16.0.0/13;
60.24.0.0/14;
60.30.0.0/16;
60.31.0.0/16;
60.208.0.0/13;
60.216.0.0/15;
60.218.0.0/15;
60.220.0.0/14;
61.48.0.0/13;
61.133.0.0/17;
61.134.96.0/19;
61.134.128.0/17;
61.135.0.0/16;
61.137.128.0/17;
61.138.0.0/17;
61.138.128.0/18;
61.139.128.0/18;
61.148.0.0/15;
61.156.0.0/16;
61.158.0.0/16;
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;
125.32.0.0/16;
125.40.0.0/13;
202.96.0.0/18;
202.96.64.0/21;
202.96.72.0/21;
202.97.128.0/18;
202.97.224.0/21;
202.97.240.0/20;
202.98.0.0/21;
202.98.8.0/21;
202.99.64.0/19;
202.99.96.0/21;
202.99.128.0/19;
202.99.160.0/21;
202.99.168.0/21;
202.99.176.0/20;
202.99.208.0/20;
202.99.224.0/21;
202.99.232.0/21;
202.99.240.0/20;
202.102.128.0/21;
202.102.224.0/21;
202.102.232.0/21;
202.106.0.0/16;
202.107.0.0/17;
202.108.0.0/16;
202.110.0.0/17;
202.111.128.0/18;
203.93.8.0/24;
203.93.192.0/18;
210.13.128.0/17;
210.14.160.0/19;
210.14.192.0/19;
210.15.32.0/19;
210.15.96.0/19;
210.15.128.0/18;
210.16.128.0/18;
210.21.0.0/16;
210.51.0.0/16;
210.52.128.0/17;
210.53.0.0/17;
210.53.128.0/17;
210.74.96.0/19;
210.74.128.0/19;
210.82.0.0/15;
211.152.0.0/13;
218.7.0.0/16;
218.8.0.0/14;
218.12.0.0/16;
218.21.128.0/17;
218.24.0.0/14;
218.28.0.0/15;
218.56.0.0/14;
218.60.0.0/15;
218.62.0.0/17;
218.67.128.0/17;
218.68.0.0/15;
218.104.0.0/14;
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.252.0.0/16;
221.0.0.0/15;
221.2.0.0/16;
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.32.0/19;
221.7.64.0/19;
221.7.96.0/19;
221.7.128.0/17;
221.8.0.0/15;
221.10.0.0/16;
221.11.0.0/17;
221.11.128.0/18;
221.11.192.0/19;
221.12.0.0/17;
221.12.128.0/18;
221.13.0.0/18;
221.13.64.0/19;
221.13.96.0/19;
221.13.128.0/17;
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.32.0/20;
221.199.128.0/18;
221.199.192.0/20;
221.200.0.0/14;
221.204.0.0/15;
221.206.0.0/16;
221.207.0.0/18;
221.207.64.0/18;
221.207.128.0/17;
221.208.0.0/14;
221.212.0.0/16;
221.213.0.0/16;
221.216.0.0/13;
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.32.0/19;
222.163.64.0/18;
222.163.128.0/17;
219.235.56.194;
};
=====================================================
named.root 文件内容
;       This file holds the information on root name servers needed to
;       initialize cache of Internet domain name servers
;       (e.g. reference this file in the "cache  .  <file>"
;       configuration file of BIND domain name servers).
;
;       This file is made available by InterNIC
;       under anonymous FTP as
;           file                /domain/named.root
;           on server           FTP.INTERNIC.NET
;       -OR-                    RS.INTERNIC.NET
;
;       last update:    Feb 04, 2008
;       related version of root zone:   2008020400
;
; formerly NS.INTERNIC.NET
;
.                        3600000  IN  NS    A.ROOT-SERVERS.NET.
A.ROOT-SERVERS.NET.      3600000      A     198.41.0.4
A.ROOT-SERVERS.NET.      3600000      AAAA  2001:503:BA3E::2:30
;
; formerly NS1.ISI.EDU
;
.                        3600000      NS    B.ROOT-SERVERS.NET.
B.ROOT-SERVERS.NET.      3600000      A     192.228.79.201
;
; formerly C.PSI.NET
;
.                        3600000      NS    C.ROOT-SERVERS.NET.
C.ROOT-SERVERS.NET.      3600000      A     192.33.4.12
;
; formerly TERP.UMD.EDU
;
.                        3600000      NS    D.ROOT-SERVERS.NET.
D.ROOT-SERVERS.NET.      3600000      A     128.8.10.90
;
; formerly NS.NASA.GOV
;
.                        3600000      NS    E.ROOT-SERVERS.NET.
E.ROOT-SERVERS.NET.      3600000      A     192.203.230.10
;
; formerly NS.ISC.ORG
;
.                        3600000      NS    F.ROOT-SERVERS.NET.
F.ROOT-SERVERS.NET.      3600000      A     192.5.5.241
F.ROOT-SERVERS.NET.      3600000      AAAA  2001:500:2f::f
;
; formerly NS.NIC.DDN.MIL
;
.                        3600000      NS    G.ROOT-SERVERS.NET.
G.ROOT-SERVERS.NET.      3600000      A     192.112.36.4
;
; formerly AOS.ARL.ARMY.MIL
;
.                        3600000      NS    H.ROOT-SERVERS.NET.
H.ROOT-SERVERS.NET.      3600000      A     128.63.2.53
H.ROOT-SERVERS.NET.      3600000      AAAA  2001:500:1::803f:235
;
; formerly NIC.NORDU.NET
;
.                        3600000      NS    I.ROOT-SERVERS.NET.
I.ROOT-SERVERS.NET.      3600000      A     192.36.148.17
;
; operated by VeriSign, Inc.
;
.                        3600000      NS    J.ROOT-SERVERS.NET.
J.ROOT-SERVERS.NET.      3600000      A     192.58.128.30
J.ROOT-SERVERS.NET.      3600000      AAAA  2001:503:C27::2:30
;
; operated by RIPE NCC
;
.                        3600000      NS    K.ROOT-SERVERS.NET.
K.ROOT-SERVERS.NET.      3600000      A     193.0.14.129
K.ROOT-SERVERS.NET.      3600000      AAAA  2001:7fd::1
;
; operated by ICANN
;
.                        3600000      NS    L.ROOT-SERVERS.NET.
L.ROOT-SERVERS.NET.      3600000      A     199.7.83.42
;
; operated by WIDE
;
.                        3600000      NS    M.ROOT-SERVERS.NET.
M.ROOT-SERVERS.NET.      3600000      A     202.12.27.33
M.ROOT-SERVERS.NET.      3600000      AAAA  2001:dc3::35
; End of File
=====================================================
 named.conf  文件内容
// Default named.conf generated by install of bind-9.2.4-28.el4
options {
        directory "/var/named";   # BIND工作目录
        dump-file "/var/named/data/cache_dump.db"; # cache 数据库
        statistics-file "/var/named/data/named_stats.txt";
        forwarders {
        61.128.128.68;
        };
        };
zone "localhost"{  
        type master;
        file "/var/named/localhost.zone";
        };
zone "0.0.127.in-addr.arpa" {  
        type master;  
        file "/var/named/localhost.rev";  
        };
 
 
include "/etc/cnc.conf";    # 调用网通IP库
view "view_cnc" in {
        match-clients { cnc; };
        recursion yes;       # 配置DNS递归解析
        additional-from-auth yes;
        additional-from-cache yes;
 
zone "." {
        type hint;
        file "/etc/named.root";
        };
zone "0002.cn" {                         
        type master;
        file "/var/named/test.cnc.zone";       # 网通解析正向区域文件
        };
 
zone "49.153.219.in-addr.arpa" {
        type master;
        file "/var/named/test.cnc.rev";        # 网通解析反向区域文件
        };
};
view "view_any" in {
        match-clients { any; };
        recursion yes;                            # 配置DNS递归解析
        additional-from-auth yes;
        additional-from-cache yes;
 
zone "." {
        type hint;
        file "/etc/named.root";
        };
 
zone "0002.cn" {
        type master;
        file "/var/named/test.tel.zone";  # 电信解析正向区域文件
        };
 
zone "49.153.219.in-addr.arpa" {
        type master;
        file "/var/named/test.tel.rev";    # 电信解析反向区域文件
        };
};
include "/etc/rndc.key";
=======================================================
test.tel.zone 文件内容
$TTL   3600    # TTL更新值
@ IN   SOA   ns.0002.cn. root.ns.0002.cn. (  
 
         20080310 
         3600 
         900 
         86400 
         15 
         )  
 
      IN NS      ns.0002.cn.   # NS地址
ns  IN   A 219.153.49.240 
    www.test.com IN CNAME www.cdn-test.com.0002.cn .  # 配置 www.test.com 的别名
    www.cdn-test.com.0002.cn . IN A 219.153.88.21
    www.cdn-test.com.0002.cn . IN A 219.153.88.20

===================================================================
test.tel.rev  文件内容
$TTL 3600
@   IN   SOA   ns.0002.cn. root.ns.0002.cn. (
         1
         28800
         14400
         3600000
         86400
         )
 
    IN   NS   ns.0002.cn.
1   IN   PTR   ns.0002.cn.
===================================================================
test.cnc.zone  文件内容
$TTL   3600 
@   IN   SOA   ns.0002.cn. root.ns.0002.cn. (  
         20080311 
         3600 
         900 
         86400 
         15 
         )  
 
       IN  NS  ns.0002.cn.
ns  IN   A 219.153.49.240 
       www.test.com IN CNAME www.cdn-test.com.0002.cn .  # 配置 www.test.com 的别名
       www.cdn-test.com.0002.cn . IN A 219.153.33.21
       www.cdn-test.com.0002.cn . IN A 219.153.33.20
==================================================================
test.cnc.rev 文件内容
$TTL 3600
@   IN   SOA   ns.0002.cn. root.ns.0002.cn. (
         1
         28800
         14400
         3600000
         86400
         )
 
    IN   NS   ns.0002.cn.
1   IN   PTR   ns.0002.cn.
==================================================================
localhost.zone  文件内容
$TTL    3600 
@       IN SOA  localhost. root.localhost. (  
                                42              ; serial (d. adams)  
                                3H              ; refresh  
                                15M             ; retry  
                                1W              ; expiry  
                                1D )            ; minimum  
 
                IN NS           localhost.  
                IN A            127.0.0.1 
==================================================================
localhost.rev  文件内容
$TTL   3600 
@   IN   SOA   localhost. root.localhost. (  
         1 
         28800 
         14400 
         3600000 
         86400 
         )  
 
    IN   NS   localhost.  
1   IN   PTR   localhost.
==================================================================
测试结果如下:
电信DNS 61.128.128.68
nslookup  www.test.com
Name:    www.cdn-test.com.0002.cn
Addresses:  219.153.88.21, 219.153.88.20
Aliases:  www.test.com , www.test.com.0002.cn
网通测试
Name:    www.cdn-test.com.0002.cn
Addresses:  219.153.33.21, 219.153.33.20
Aliases:  www.test.com , www.test.com.0002.cn
 

你可能感兴趣的:(职场,休闲,BIND智能解析域名)