环境和目标
在我的测试 KVM 实验室中,我有一个虚拟网络172.16.50/24
,在这个网络中,我有 2 个运行 Bind 9 和 ISC DHCP 服务器的 Centos 7 VM:
- Мастер DNS :
controller.wsvirt.home (172.16.50.2)
- 从属 DNS:
controller2.wsvirt.home (172.16.50.3)
网络中的所有客户端都是 Linux VM,它们都从 DHCP 服务器获取网络配置。此服务器动态更新 DNS 区域。
Bind 9 是wsvirt.home
zone 的权威服务器。
在实验室环境中,我测试了一个必须在我们的商务办公网络中实现的场景。在业务环境中,我应该创建一个 AD 域来为 Windows 客户端提供服务,为此我们决定使用 Samba 4 作为 DC。我已经为 Centos 7 构建了一个 Samba 服务器,并从源代码中获得了 Heimdal Kerberos 支持。
对于 AD,我分配了子网172.16.50.192/26
和分配的ad.wsvirt.home
域。
AD DC 是一个运行 Samba 4、Bind 9 和 ISC DHCP 服务器的 Centos 7 VM。Samba 使用 BIND_DLZ 作为 DNS 后端。AD 控制器具有addc1.ad.wsvirt.home
域名和IP 172.16.50.193
.
所有 Windows AD 客户端从动态更新绑定 DLZ 区域的 AD DC 上运行的 DHCP 服务器获取 IP。
在真实的工作物理环境中,来自两个网络的所有客户端 PC 都应该连接到一个广播域。
为了满足要求,我根据 [RFC 2317][1]将服务器上的 Bind 中的正向ad.wsvirt.home
和反向DNS 区域授权给 AD 控制器。172.16.50.192/26
controller.wsvirt.home
addc1.ad.wsvirt.home
# 问题 #
除了一件事,一切都完美无缺。当我在 AD DC 上测试委托反向区域的反向查找时,结果看起来不错,因此 Windows AD 客户端可以解析两个域中的所有反向域名。:
$ dig -x 172.16.50.193 @addc1.ad.wsvirt.home
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> -x 172.16.50.193 @addc1.ad.wsvirt.home
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43507
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;193.50.16.172.in-addr.arpa. IN PTR
;; ANSWER SECTION:
193.50.16.172.in-addr.arpa. 86400 IN CNAME 193.50.16.172.ddns.
193.50.16.172.ddns. 900 IN PTR addc1.ad.wsvirt.home.
;; Query time: 7 msec
;; SERVER: 172.16.50.193#53(172.16.50.193)
;; WHEN: Mon Mar 30 21:05:12 IDT 2020
;; MSG SIZE rcvd: 121
但是当我将我的请求路由到 DNS 服务器 ```controller.wsvirt.home``` 时,它不会从 ``ad.wsvirt.home``` 域解析任何反向名称,因此 Linux 客户端无法查找任何反向名称:
$ dig -x 172.16.50.193 @controller.wsvirt.home
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> -x 172.16.50.193 @controller.wsvirt.home
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 48825
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;193.50.16.172.in-addr.arpa. IN PTR
;; ANSWER SECTION:
193.50.16.172.in-addr.arpa. 86400 IN CNAME 193.50.16.172.ddns.
;; AUTHORITY SECTION:
. 8133 IN SOA a.root-servers.net. nstld.verisign-grs.com. 2020033001 1800 900 604800 86400
;; Query time: 0 msec
;; SERVER: 172.16.50.2#53(172.16.50.2)
;; WHEN: Mon Mar 30 21:49:41 IDT 2020
;; MSG SIZE rcvd: 162
**我需要**来自 ```wsvirt.home``` 域的 Linux 客户端能够解析 ```ad.wsvirt.home``` 域中的反向域名。有可能吗?
#配置#
更准确地说,我将两台服务器的配置文件放在这里
服务器控制器.wsvirt.home
/etc/named.conf
acl local { 172.16.50.0/24; 127.0.0.1; };
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
include "/etc/rndc.key";
server 172.16.50.3 {
keys { "rndc-key"; };
};
...
options {
listen-on port 53 { local; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
allow-query { local; };
allow-transfer { none; };
notify no;
forwarders { 8.8.8.8; 8.8.4.4; };
forward only;
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
bindkeys-file "/etc/named.iscdlv.key";
managed-keys-directory "/var/named/dynamic";
pid-file "/run/named/named.pid";
session-keyfile "/run/named/session.key";
};
zone "." IN {
type hint;
file "named.ca";
};
zone "wsvirt.home" IN {
type master;
file "wsvirt.home.db";
allow-update { key "rndc-key"; };
allow-transfer { key "rndc-key"; };
notify yes;
forwarders {};
};
zone "50.16.172.in-addr.arpa" IN {
type master;
file "50.16.172.db";
allow-update { key "rndc-key"; };
allow-transfer { key "rndc-key"; };
notify yes;
};
### /var/named/50.16.172.db ### ``` $ORIGIN 。$TTL 86400 ; 1 天 50.16.172.in-addr.arpa 在 SOA 控制器.wsvirt.home。root.wsvirt.home。(153;串行 3600;刷新(1 小时)1800;重试(30 分钟)604800;过期(1 周)86400;最少(1 天))NS controller.wsvirt.home。NS 控制器 2.wsvirt.home。$ORIGIN 50.16.172.in-addr.arpa。2 PTR 控制器.wsvirt.home。$TTL 86400 ; 1 天 3 PTR controller2.wsvirt.home。... ; 50.16.172.ddns。在 NS addc1.ad.wsvirt.home。$GENERATE 193-254 $ CNAME $.50.16.172.ddns。```
### /etc/dhcp/dhcpd.conf ### ``` include "/etc/rndc.key";
默认租赁时间 600;最大租赁时间 7200;权威性; ddns-update-style 过渡;
class "windows" {
match if substring (option vendor-class-identifier, 0, 8) = "MSFT 5.0"; }
子网 172.16.50.0 网络掩码 255.255.255.0 { log (info, concat("Vendor Class ID (60): ", option vendor-class-identifier)); log (info, concat("DHCP Client ID (61): ", option dhcp-client-identifier)); log (info, concat("User Class ID (77): ", option user-class)); 选项域名服务器 172.16.50.2、172.16.50.3;选项 ntp-servers 172.16.50.2;选项路由器 172.16.50.1;选项广播地址 172.16.50.255;默认租赁时间 600;最大租赁时间 7200;选项 ip-forwarding off; 忽略客户端更新;选项域名“wsvirt.home”;选项域搜索“wsvirt.home”;选项 netbios 范围“”;选项 netbios-node-type 8; 选项 netbios-name-servers 172.16.50.2;选项 netbios-dd-server 172.16.50.2;ddns 更新;ddns-域名 "wsvirt.home."; ddns-rev-域名"
pool {
range 172.16.50.21 172.16.50.190;
deny members of "windows";
}
zone wsvirt.home {
primary 172.16.50.2;
key "rndc-key";
}
zone 50.16.172.in-addr.arpa {
primary 172.16.50.2;
key "rndc-key";
}
}
<br />
## AD DC addc1.ad.wsvirt.home ##
### /etc/named.conf ###
选项 { 监听端口 53 { 任何;}; 监听 v6 端口 53 { ::1; }; 目录“/var/named”;转储文件“/var/named/data/cache_dump.db”;统计文件“/var/named/data/named_stats.txt”;memstatistics-file "/var/named/data/named_mem_stats.txt"; 递归文件“/var/named/data/named.recursing”;secroots-file "/var/named/data/named.secroots"; 允许查询{任何;}; 转发器 { 172.16.50.2; 172.16.50.3;}; 仅转发;递归是的;dnssec-启用否;dnssec-验证号;bindkeys-file "/etc/named.root.key"; 托管键目录“/var/named/dynamic”;pid-file "/run/named/named.pid"; session-keyfile "/run/named/session.key"; tkey-gssapi-keytab "/var/lib/samba/private/dns.keytab"; 最小响应是的;};
...
区“。” IN {类型提示;文件“named.ca”;};
包括“/etc/rndc.key”;包括“/etc/named.rfc1912.zones”;包括“/etc/named.root.key”;包括“/var/lib/samba/bind-dns/named.conf”;
<br />
### /etc/dhcp/dhcpd.conf ###
包括“/etc/rndc.key”;
默认租赁时间 600;最大租赁时间 7200;分秒 5;权威性; ddns-update-style 无;
class "others" { match if substring (option vendor-class-identifier, 0, 8) != "MSFT 5.0"; }
子网 172.16.50.192 网络掩码 255.255.255.192 { log (info, concat("Vendor Class ID (60): ", option vendor-class-identifier)); log (info, concat("DHCP Client ID (61): ", option dhcp-client-identifier)); log (info, concat("User Class ID (77): ", option user-class)); 选项路由器 172.16.50.1;选项广播地址 172.16.50.255;默认租赁时间 600;最大租赁时间 7200;选项 ip-forwarding off; 忽略客户端更新;选项 ntp-servers 172.16.50.193;选项域名服务器 172.16.50.193;选项域名“ad.wsvirt.home”;选项域搜索“ad.wsvirt.home”;选项 netbios-name-servers 172.16.50.193;选项 netbios-dd-server 172.16.50.193;选项 netbios 范围“”;选项 netbios-node-type 8; ddns-rev-域名“ddns”;
pool {
range 172.16.50.210 172.16.50.254;
deny members of "others";
}
}
提交时 { set noname = concat("dhcp-", binary-to-ascii(10, 8, "-", leased-address)); 设置 ClientIP = binary-to-ascii(10, 8, ".", 租用地址); set ClientDHCID = concat ( suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,1,1))),2), ":", suffix (concat ("0 ", binary-to-ascii (16, 8, "", substring(hardware,2,1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8 , "", substring(hardware,3,1))),2), ":", 后缀 (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,4,1 ))),2), ":", 后缀 (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,5,1))),2), ":",后缀 (concat ("0", binary-to-ascii (16, 8, "", 子字符串(硬件,6,1))),2));设置客户端名称 = 选择第一个值(选项主机名、配置选项主机名、客户端名称、无名);log(concat("Commit: IP: ", ClientIP, " DHCID: ", ClientDHCID, " Name: ", ClientName)); 执行("/usr/local/sbin/dhcp-dyndns.sh", "add", ClientIP, ClientDHCID, ClientName); }
发布时 {
设置 ClientIP = binary-to-ascii(10, 8, ".", 租用地址); set ClientDHCID = concat ( suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,1,1))),2), ":", suffix (concat ("0 ", binary-to-ascii (16, 8, "", substring(hardware,2,1))),2), ":", suffix (concat ("0", binary-to-ascii (16, 8 , "", substring(hardware,3,1))),2), ":", 后缀 (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,4,1 ))),2), ":", 后缀 (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,5,1))),2), ":",后缀(concat ("0", binary-to-ascii (16, 8, "", substring(hardware,6,1))),2) );log(concat("发布:IP:", ClientIP)); 执行(“/usr/local/sbin/dhcp-dyndns.sh”,“删除”,ClientIP,ClientDHCID);}
到期时 {
设置 ClientIP = binary-to-ascii(10, 8, ".", 租用地址); log(concat("过期:IP:", ClientIP)); 执行(“/usr/local/sbin/dhcp-dyndns.sh”,“删除”,客户端IP,“”,“0”);}
<br />
### A DLZ revers zone 50.16.172.ddns on the AD DC ###
$ samba-tool dns query localhost 50.16.172.ddns @ALL [[email protected]] 的密码:Name=, Records=2, Children=0 SOA: serial=3, refresh=900, retry=600,过期=86400,minttl=3600,ns=addc1.ad.wsvirt.home.,电子邮件=hostmaster.ad.wsvirt.home。(标志=600000f0,序列=3,ttl=3600)NS:addc1.ad.wsvirt.home。(flags=600000f0, serial=1, ttl=3600) Name=193, Records=1, Children=0 PTR: addc1.ad.wsvirt.home (flags=f0, serial=3, ttl=900) Name=230, Records=1, Children=0 PTR: winxp-1.ad.wsvirt.home (flags=f0, serial=3, ttl=3600)
[1]: https://www.rfc-editor.org/rfc/rfc2317