view "lan" { //定义内网view,命名为lan
match-clients { 10.0.0.0/24; }; //设定可解析的客户端,此处可以是具体的IP,也可是网段,也可是我们定义的ACL(ACL的定义方式这里不细说)
zone "localhost.localdomain" IN {
type master;
file "named.localhost";
allow-update { none; };
};
zone "localhost" IN {
type master;
file "named.localhost";
allow-update { none; };
};
zone "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {
type master;
file "named.loopback";
allow-update { none; };
};
zone "1.0.0.127.in-addr.arpa" IN {
type master;
file "named.loopback";
allow-update { none; };
};
zone "0.in-addr.arpa" IN {
type master;
file "named.empty";
allow-update { none; };
};
zone "jinsanhong.com" IN { //这个zone就是我们要解析的区域
type master; //类型,类型有hint,master,Slave,swap。Hint是根区域类型,master和slave是用来做DNS的主从,swap是交换类型。
file "jinsanhong.com.lan"; //定义区域解析库文件,此路径是相对路径,相对named.conf中 directory "/var/named"这个路径,所以区域解析文件要放在/var/named下。
};
zone "." IN {
type hint;
file "named.ca";
};
};
view "wan" { //这是我们定义的外网view
match-clients { 192.168.2.0/24; };
zone "jinsanhong.com" IN {
type master;
file "jinsanhong.com.wan";
};
};
Vim jinsanhong.com.lan
$TTL 1D
@ IN SOA ns.jinsanhong.com. admin.jinsanhong.com. (
2015081310 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS ns.jinsanhong.com.
ns.jinsanhong.com. IN A 10.0.0.3 //这是DNS服务器内网卡IP www.jinsanhong.com. IN A 10.0.0.2 //解析的web服务地址
1
2
3
4
5
6
7
8
9
10
11
Vim welcome.zone.wan
$TTL 1D
@ IN SOA ns.jinsanhong.com. admin.jinsanhong.com. (
2015081310 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS ns.jinsanhong.com.
ns.jinsanhong.com. IN A 192.168.2.80 //这是DNS服务器外网卡IP www.jinsanhong.com. IN A 192.168.2.80 // 解析的web服务地址
2、
view "other" {
zone "." IN {
type hint;
file "named.ca";
};
};
将所有的zone都放在视图下。
错误二
1
2
3
4
5
6
jinsanhong.com.lan:9: ignoring out-of-zone data (ns.jisanhong.com)
zone jinsanhong.com/IN: NS 'ns.jinsanhong.com' has no address records (A or AAAA)
zone jinsanhong.com/IN: not loaded due to errors.
lan/jinsanhong.com/IN: bad zone
zone jinsanhong.com/IN: loaded serial 2015081310
[FAILED]