出于历史原因,我们有内部IP (192.168.0.0/16)和主机上的公共IP (example.com)。我现在想把它分开,这样就不会为外部用户解析内部主机名了。
我目前的计划是在RPZ中使用bind。
我的named.conf如下:
options {
directory "/var/named";
pid-file "/run/named/named.pid";
// Uncomment these to enable IPv6 connections support
// IPv4 will still work:
// listen-on-v6 { any; };
// Add this for no IPv4:
// listen-on { none; };
allow-recursion { localhost; };
allow-transfer { none; };
allow-update { none; };
version none;
hostname none;
server-id none;
response-policy { zone "rpz"; };
};
zone "localhost" IN {
type master;
file "localhost.zone";
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "127.0.0.zone";
};
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" {
type master;
file "localhost.ip6.zone";
};
zone "255.in-addr.arpa" IN {
type master;
file "empty.zone";
};
zone "0.in-addr.arpa" IN {
type master;
file "empty.zone";
};
zone "." IN {
type hint;
file "root.hint";
};
zone "rpz" {type master; file "rpz"; allow-query {localhost;}; };我的rpz区域文件如下:
$TTL 1H
@ SOA LOCALHOST. named-mgr.example.com (16 1h 15m 30d 2h)
@ IN NS localhost.
support.example.com A 192.168.1.1
cname.example.com CNAME support.example.com
*.example.com CNAME rpz-passthru.
* CNAME .当我查询support.example.com时,我得到了我想要的结果:
# dig +short support.example.com @127.0.0.1
192.168.1.1但是,当我查询cname.example.com时,IP是解析的,但是客户端被告知他位于RPZ区域。
# dig +short cname.example.com @127.0.0.1
support.example.com.rpz.
192.168.1.1或者,我可以在区域文件中更改CNAME,如下所示:
cname.example.com CNAME support.example.com. ;mind the period at the end但这将阻止bind递归解析cname:
# dig +short cname.example.com @127.0.0.1
support.example.com.
# dig +short support.example.com. @127.0.0.1
192.168.1.1你能解释我做错了什么吗?
谢谢克莱门斯
发布于 2019-07-30 15:09:09
这是一个相当晚的答复,但这已经在isc邮寄名单上得到了回答。不幸的是,您不能将多个rpz-记录链接在一起,例如
cname.example.com CNAME support.example.com.
support.example.com A 192.168.1.1rpz是一个一次性操作。如果查询导致2次查找(在涉及CNAME时自动发生)--只有第一次查找将由rpz处理。
您需要将配置更改为
cname.example.com A 192.168.1.1
support.example.com A 192.168.1.1..。其中,每个条目只能通过一个查找来回答。
当不使用cname记录时,您也不需要担心cname记录后面的时间段的必要性;)
无论如何,如果您必须在rpz文件中使用CNAME记录,那么请添加句号。对于rpz,其他一切都没有多大意义。
https://serverfault.com/questions/885619
复制相似问题