view 实现区域解析视图

操作系统:linux
BIND版本:BIND 9.2.4-5
DNS 服务器:192.168.1.1
企业内部(lan)IP段:192.168.1.0/24
企业外部(wan)IP段:除192.168.1.0/24之外的所有
域名:testdns.org
我们希望企业内部IP所解析到
www.testdns.org
的IP地址为:192.168.1.3,外部IP段则解析到:192.168.1.100;
named.conf
options {
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
/** If there is a firewall between you and nameservers you want
* to talk to, you might need to uncomment the query-source
* directive below. Previous versions of BIND always asked
* questions using port 53, but BIND 8.1 uses an unprivileged
* port by default.
*/
// query-source address * port 53;
};
//
// a caching only nameserver config
//
controls {
   inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};
view "lan" {
   match-clients {
      192.168.1.0/24;
      };
zone "." IN {
   type hint;
   file "named.ca";
   };
zone "testdns.com" {
   type master;
   file "testdns.zone";
   };
zone "0.0.127.in-addr.arpa" IN {
   type master;
   file "named.local";
   allow-update { none; };
   };
};
view "wan" {
   match-clients { any;!192.168.1.0/24 };
zone "." IN {
   type hint;
   file "named.ca";
   };
zone "testdns.com" {
   type master;
   file "testdns.wan.zone";
   };
zone "0.0.127.in-addr.arpa" IN {
   type master;
   file "named.local";
   allow-update { none; };
   };
};
include "/etc/rndc.key";
创建数据库文件:
vi /var/named/testdns.zone
$TTL 86400
$ORIGIN testdns.com.
@ IN SOA ns.testdns.com. admin.testdns.com. (
       200512264
       60
       60
       36000
       86400 )
        IN       NS      ns.testdns.com.
    @    IN    A    192.168.1.1
    ns   IN    A    192.168.1.1
    www   IN   A    192.168.1.3
vi /etc/named/testdns.wan.zone
$TTL 86400
$ORIGIN testdns.com.
@ IN SOA ns.testdns.com. admin.testdns.com. (
        200512
        60
        60
        36000
        86400 )
   IN   NS    ns.testdns.com.
   @    IN    A   192.168.1.1
   ns    IN    A    192.168.1.1
   www   IN     A    192.168.1.100
通过以上的步骤对dns中的解析视图配好了。
启动:service named start
测试:
用内网中的ip地址来测试,可以用nslookup来进行。
用外网来访问,例如192.168.9.55这个ip地址,那么我们首先要在服务器中要添加这块路由,要让这两台机器能相互连通,添加命令为:
route add -net 192.168.9.0 netmask 255.255.255.0 dev eth0   这样就在服务器上添加好了。我们还要在所在这台的客户机上添加路由,如下:
route add 192.168.1.0 mask 255.255.255.0 192.168.9.55     然后进行测试,就能看到结果了。
以上所述比较详细,若有不懂请联系我 [email protected]。谢谢大家的支持,欢迎继续访问。

你可能感兴趣的:(职场,view,休闲)