我已在 Ubuntu 16.04 VM 上设置了 ISC 的 BIND 和 DHCP 实现,作为具有权威 DHCP 的权威名称服务器。我的目标是对静态和 DHCP 地址的混合mobile.mydomain.org
具有权威性。int.mydomain.org
这是我的named.conf.local
:
key DHCP_UPDATER {
algorithm HMAC-MD5.SIG-ALG.REG.INT;
secret "abcde";
};
zone "int.mydomain.org" {
type master;
file "/etc/bind/zones/db.int.mydomain.org";
allow-transfer { 192.168.1.3; };
allow-update { key DHCP_UPDATER; };
};
zone "0.168.192.in-addr.arpa" {
type master;
file "/etc/bind/zones/db.192.168.0";
allow-update { key DHCP_UPDATER; };
};
zone "1.168.192.in-addr.arpa" {
type master;
file "/etc/bind/zones/db.192.168.1";
allow-update { key DHCP_UPDATER; };
};
zone "mobile.mydomain.org" {
type master;
file "/etc/bind/zones/db.mobile.mydomain.org";
allow-transfer { 192.168.1.3; };
allow-query { 172.16.0.1/22; };
allow-update { key DHCP_UPDATER; };
};
zone "0.16.172.in-arpa.arpa" {
type master;
file "/etc/bind/zones/db.172.16.0";
allow-update { key DHCP_UPDATER; };
};
静态分配的域名得到正确解析,因此不存在问题。DHCP 地址从此处分配dhcpd.conf
:
ignore client-updates;
ddns-update-style none;
option domain-name-servers 192.168.1.2, 192.168.1.3;
default-lease-time 60;
max-lease-time 720;
authoritative;
log-facility local7;
key DHCP_UPDATER {
algorithm HMAC-MD5.SIG-ALG.REG.INT;
secret "abcde";
};
subnet 192.168.0.0 netmask 255.255.252.0 {
range 192.168.2.1 192.168.3.250;
option domain-name-servers 192.168.1.2, 192.168.1.3;
option domain-name "int.mydomain.org";
option subnet-mask 255.255.252.0;
option routers 192.168.0.1;
option broadcast-address 192.168.3.255;
default-lease-time 60;
max-lease-time 720;
}
zone int.reboot3times.org. {
primary 192.168.1.2;
key DHCP_UPDATER;
}
zone 0.168.192.in-addr.arpa. {
primary 192.168.1.2;
key DHCP_UPDATER;
}
zone 1.168.192.in-addr.arpa. {
primary 192.168.1.2;
key DHCP_UPDATER;
}
zone 2.168.192.in-addr.arpa. {
primary 192.168.1.2;
key DHCP_UPDATER;
}
zone 3.168.192.in-addr.arpa. {
primary 192.168.1.2;
key DHCP_UPDATER;
}
subnet 172.16.0.0 netmask 255.255.252.0 {
range 172.16.0.20 172.16.3.255;
option domain-name-servers 192.168.1.2, 192.168.1.3;
option domain-name "mobile.mydomain.org";
option subnet-mask 255.255.252.0;
option routers 172.16.0.1;
option broadcast-address 172.16.3.255;
default-lease-time 60;
max-lease-time 720;
}
zone 0.16.172.in-addr.arpa. {
primary 192.168.1.2;
key DHCP_UPDATER;
}
DHCP 地址根据请求分配,我已用该地址部署了多个虚拟机。以下是示例:
$ cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 192.168.1.2
nameserver 192.168.1.3
search int.mydomain.org
我的问题是无法解析 DHCP 分配的地址。阅读论坛和博客文章后,我的理解是,我可以使用 DHCP 服务器和 DNS 服务器的共享密钥来允许主机名更新,但这样做不起作用。
如何使用 DHCP 分配的地址动态更新 DNS 服务器?
答案1
你仍然ddns-update-style none
在 dhcpd.conf 中。你读过的文章应该提到将其设置为,interim
以及设置ddns-updates on
。看看https://wiki.debian.org/DDNS举一些不错的例子。