利用view实现智能DNS
环境:
DNS主服务器 192.168.88.7
DNS客户端1 192.168.88.17
DNS客户端2 172.16.1.37
DNS客户端3 10.0.0.7
DNS主服务:
#配置IP地址
ens32:192.168.88.7/24
ens33: 172.16.1.7/24
ip a a 10.0.0.7/24 dev ens32
yum install bind -y
#在 option前面加上
acl bejing{
192.168.88.0/24;
};
acl suzhou {
172.16.1.0/24;
};
acl othernet {
any;
};
#在option里面,注释掉下面两行
// listen-on port 53 { 127.0.0.1; };
// allow-query { localhost; };
创建view
view bjview {
match-clients { beijing;};
include "/etc/named.rfc1912.zones.bj";
};
view szview {
match-clients { suzhou;};
include "/etc/named.rfc1912.zones.sz";
};
view otherview {
match-clients { othernet;};
include "/etc/named.rfc1912.zones.other";
};
#实现区域配置文件
vim /etc/named.rfc1912.zones.bj
zone "." IN {
type hint;
file "named.ca";
};
zone "wswj.com" {
type master;
file "wswj.com.zone.bj";
};
vim /etc/named.rfc1912.zones.sz
zone "." IN {
type hint;
file "named.ca";
};
zone "wswj.com" {
type master;
file "wswj.com.zone.sz";
};
vim /etc/named.rfc1912.zones.other
zone "." IN {
type hint;
file "named.ca";
};
zone "wswj.com" {
type master;
file "wswj.com.zone.other";
};
chgrp named /etc/named.rfc1912.zones.bj
chgrp named /etc/named.rfc1912.zones.sz
chgrp named /etc/named.rfc1912.zones.other
#创建区域数据库文件
[root@localhost named]# vim wswj.com.zone.bj
$TTL 1D
@ IN SOA master admin. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS master
master A 192.168.88.7
www A 192.168.88.111
[root@localhost named]# vim wswj.com.zone.sz
$TTL 1D
@ IN SOA master admin. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS master
master A 172.16.1.7
www A 172.16.1.111
[root@localhost named]# vim wswj.com.zone.other
$TTL 1D
@ IN SOA master admin. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS master
master A 10.0.0.7
www A 10.0.0.7
systemctl enable --now named.service
分别在客户端测试
dig www.wswj.com



京公网安备 11010502036488号