edns-client-subnet(下简称ecs)其现在还没有正式被bind支持。需要对bind重新编译,ISC上有支持ecs authoritative的源码,git克隆到到本地编译即可。
从国内镜像库check出bind代码,因为ecs功能只是在某个提交里面,故需要checkou一下:(后面版本是否也支持,测试确认)
ecs commit 对象: git checkout d46855caedd5cb101795707f6f467fa363ef1448
国内镜像:https://github.com/isc-projects/bind9.git
完成的环境:
[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
安装
git clone https://source.isc.org/git/bind9.git
cd bind9/
./configure
make && make install
或者 指定安装完成目录:
./configure --prefix=/data/build/bind --without-openssl
既可以将bind安装完成。
安装完成后,可能named.conf没有生成,需要手动生成,或者从网上down一份作为主配置文件
---------------------------------------------如上是安装过程-------------------------------------------------
使用了两个view,每个view内分别由acl以及zone文件,比较好的小李子(详细部署文件见附件bind.ecs.ok.viewzoneok.bk.tar)
acl localnet{
ecs 120.0.0.1/24;
};
acl externet{
any;
};
options {
directory "/var/named"; # 指定bind主目录
};
view internal { #intermal视图配置
match-clients { localnet; }; #只有匹配localnet的用户进入internal域解析
recursion yes; #允许递归
zone "." IN { #根域解析
type hint; #区域类型为提示域
file "named.ca"; #指定根域的解析文件,可用dig -t a .>/var/named/named.ca生成
};
zone "zhxfei.com" IN {
type master;
file "zhxfei.com.localnet.zone"; #指定区域解析文件
allow-transfer { none; };
};
};
view external {
match-clients { externet; }; #不匹配ecs的用户进入此视图解析
recursion no; #不允许递归
zone "." IN { #根域解析
type hint; #区域类型为提示域
file "named.ca"; #指定根域的解析文件,可用dig -t NS .>/var/named/named.ca生成
};
zone "zhxfei.com" IN {
type master; #指定bind对这个区域的解析角色
file "zhxfei.com.externnet.zone"; #指定区域解析文件
allow-transfer { none; }; #不允许区域传送
};
};