环境debian6.0X64

实现福州访问指向1.1.1.1

北京访问指向2.2.2.2

1.安装dns

apt-get install bind9 dnsutils

2.创建dns 主目录 master

mkdir -p /etc/bind/zones/master
3.创建 福州和北京两地域名的解析
touch /etc/bind/zones/master/fz.demo_com
touch /etc/bind/zones/master/bj.demo_com

4.编辑named.conf添加dns判断

vim named.conf

include "/etc/bind/named.conf.options";

include "/etc/bind/named.conf.local";
#include "/etc/bind/named.conf.default-zones";
acl "fz" {
192.168.1.0/24;
} ;
view "internal" {
match-clients { fz; };
recursion yes;
include "/etc/bind/named.conf.default-zones";
zone "demo.com" {
type master;
file "/etc/bind/zones/master/fz.demo_com";
};
};
view "external" {
match-clients { any; };
recursion no;
include "/etc/bind/named.conf.default-zones";
zone "demo.com" {
        type master;
        file "/etc/bind/zones/master/bj.demo_com";
};
};
注意:
如果不注释#include "/etc/bind/named.conf.default-zones";

启动dns就会报错提示:

 /etc/named.conf:14: when using 'view' statements, all zones must be in views

经过查询:
如果使用了view,那就不能在主文件单独定义了啦,可怜的,必须在每个view里面都定义每个zone
但是,如果你不需要根据每个view处理不一样的,你可以在每个view都引用同一个解析文件