bind区域视图

蒜香大龙虾 2025-05-28 09:35:56
Categories: Tags:

环境

linux1作为dns主域服务器
linux2-3作为测试客户端

搭建区域

创建视图区域

删除 /etc/named.conf 内的默认区域

1
2
3
4
5
6
7
# 要删掉的东西
zone "." IN {
type hint;
file "named.ca";
};

include "/etc/named.rfc1912.zones";

修改/etc/named.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
...
acl guangzhou {172.20.20.11;};
view guangzhou {
match-clients { guangzhou; };
zone "." IN {
type hint;
file "named.ca";
};
zone "skills.top" IN {
type master;
file "gz.zone";
};
};

acl foshan {172.20.20.12;};
view foshan {
match-clients { foshan; };
zone "." IN {
type hint;
file "named.ca";
};
zone "skills.top" IN {
type master;
file "fs.zone";
};
};

acl shenzhen {172.20.20.13;};
view shenzhen {
match-clients { shenzhen; };
zone "." IN {
type hint;
file "named.ca";
};
zone "skills.top" IN {
type master;
file "sz.zone";
};
};

view default {
match-clients { any; };
zone "." IN {
type hint;
file "named.ca";
};
zone "skills.com" IN {
type master;
file "skills.zone";
};
};

# zone "." IN {
# type hint;
# file "named.ca";
# };

# include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";

添加正向区域

1
2
3
4
5
cd /var/named
for i in {gz,fs,sz};do cp -a named.localhost $i.zone;done
echo "test A 1.1.1.1" >> gz.zone
echo "test A 2.2.2.2" >> fs.zone
echo "test A 3.3.3.3" >> sz.zone

测试

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[root@linux1 ~]# nslookup test.skills.top
Server: 172.20.20.11
Address: 172.20.20.11#53

Name: test.skills.top
Address: 1.1.1.1

[root@linux2 ~]# nslookup test.skills.top
Server: 172.20.20.11
Address: 172.20.20.11#53

Name: test.skills.top
Address: 2.2.2.2

[root@linux3 ~]# nslookup test.skills.top
Server: 172.20.20.11
Address: 172.20.20.11#53

Name: test.skills.top
Address: 3.3.3.3

参考链接如下:
https://kb.isc.org/docs/aa-00851
https://blog.csdn.net/muxia_jhy/article/details/126608750