Mar*_*rco 9 domain-name-system bind ddns nameserver dynamic-dns
我正在尝试使用 nsupdate 动态更新我的 DNS 服务器。
我在我的 DNS 服务器上使用 Debian 6,在我的客户端上使用 Debian 4。
我使用以下方法创建了一个公钥/私钥对:
dnssec-keygen -C -a HMAC-MD5 -b 512 -n USER sub.example.com.
Run Code Online (Sandbox Code Playgroud)
然后我编辑了我的named.conf.local以包含我的公钥和我希望更新的新区域。现在看起来像这样(注意:我也尝试过allow-update { any; };没有成功):
zone "example.com" {
type master;
file "/etc/bind/primary/example.com";
notify yes;
allow-update { none; };
allow-query { any; };
};
zone "sub.example.com" {
type master;
file "/etc/bind/primary/sub.example.com";
notify yes;
allow-update { key "sub.example.com."; };
allow-query { any; };
};
key sub.example.com. {
algorithm HMAC-MD5;
secret "xxxx xxxx";
};
Run Code Online (Sandbox Code Playgroud)
接下来,我将私钥文件 ( key.private )复制到我想从中更新区域的另一台服务器。我还在这台服务器上创建了一个包含更新信息的文本文件(更新)(注意:我也尝试玩弄这些东西。没有成功):
server example.com
zone sub.example.com
update add sub.example.com. 86400 A 10.10.10.1
show
send
Run Code Online (Sandbox Code Playgroud)
现在我正在尝试使用以下方法更新区域:
nsupdate -k key.private -v update
Run Code Online (Sandbox Code Playgroud)
所述命令给了我以下输出:
Outgoing update query:
;; ->>HEADER<<- opcode: UPDATE, status: NOERROR, id: 0
;; flags: ; ZONE: 0, PREREQ: 0, UPDATE: 0, ADDITIONAL: 0
;; ZONE SECTION:
;sub.example.com. IN SOA
;; UPDATE SECTION:
sub.example.com. 86400 IN A 10.10.10.1
update failed: SERVFAIL
Run Code Online (Sandbox Code Playgroud)
当我在远程服务器上发出 nsupdate 命令时,named debug Level 3 为我提供了以下信息(注意:我混淆了客户端 IP):
06-Aug-2012 14:51:33.977 client X.X.X.X#33182: new TCP connection
06-Aug-2012 14:51:33.977 client X.X.X.X#33182: replace
06-Aug-2012 14:51:33.978 clientmgr @0x2ada3c7ee760: createclients
06-Aug-2012 14:51:33.978 clientmgr @0x2ada3c7ee760: recycle
06-Aug-2012 14:51:33.978 client @0x2ada475f1120: accept
06-Aug-2012 14:51:33.978 client X.X.X.X#33182: read
06-Aug-2012 14:51:33.978 client X.X.X.X#33182: TCP request
06-Aug-2012 14:51:33.978 client X.X.X.X#33182: request has valid signature
06-Aug-2012 14:51:33.978 client X.X.X.X#33182: recursion not available
06-Aug-2012 14:51:33.978 client X.X.X.X#33182: update
06-Aug-2012 14:51:33.978 client X.X.X.X#33182: send
06-Aug-2012 14:51:33.978 client X.X.X.X#33182: sendto
06-Aug-2012 14:51:33.979 client X.X.X.X#33182: senddone
06-Aug-2012 14:51:33.979 client X.X.X.X#33182: next
06-Aug-2012 14:51:33.979 client X.X.X.X#33182: endrequest
06-Aug-2012 14:51:33.979 client X.X.X.X#33182: read
06-Aug-2012 14:51:33.986 client X.X.X.X#33182: next
06-Aug-2012 14:51:33.986 client X.X.X.X#33182: request failed: end of file
06-Aug-2012 14:51:33.986 client X.X.X.X#33182: endrequest
06-Aug-2012 14:51:33.986 client X.X.X.X#33182: closetcp
Run Code Online (Sandbox Code Playgroud)
但它没有任何作用。区域没有更新,我的 nsupdate 也没有改变任何东西。我不确定文件/etc/bind/primary/sub.example.com在第一次更新之前是否应该存在。我在没有文件的情况下尝试了它,有一个空文件和一个预配置的区域文件。没有成功。
我在网上找到的稀疏信息将我指向有关绑定工作目录的文件和文件夹权限,因此我更改了/etc/bind和/var/cache/bind(这是我的“绑定”的主目录)的权限用户)。
我不是 100% 确定权限是否正确..但对我来说看起来不错:
ls -lah /var/cache/bind/
total 224K
drwxrwxr-x 2 bind bind 4.0K Aug 6 03:13 .
drwxr-xr-x 12 root root 4.0K Jul 21 11:27 ..
-rw-r--r-- 1 bind bind 211K Aug 6 03:21 named.run
ls -lah /etc/bind/
total 72K
drwxr-sr-x 3 bind bind 4.0K Aug 6 14:41 .
drwxr-xr-x 87 root root 4.0K Jul 30 01:24 ..
-rw------- 1 bind bind 125 Aug 6 02:54 key.public
-rw------- 1 bind bind 156 Aug 6 02:54 key.private
-rw-r--r-- 1 bind bind 2.5K Aug 6 03:07 bind.keys
-rw-r--r-- 1 bind bind 237 Aug 6 03:07 db.0
-rw-r--r-- 1 bind bind 271 Aug 6 03:07 db.127
-rw-r--r-- 1 bind bind 237 Aug 6 03:07 db.255
-rw-r--r-- 1 bind bind 353 Aug 6 03:07 db.empty
-rw-r--r-- 1 bind bind 270 Aug 6 03:07 db.local
-rw-r--r-- 1 bind bind 3.0K Aug 6 03:07 db.root
-rw-r--r-- 1 bind bind 493 Aug 6 03:32 named.conf
-rw-r--r-- 1 bind bind 490 Aug 6 03:07 named.conf.default-zones
-rw-r--r-- 1 bind bind 1.2K Aug 6 14:18 named.conf.local
-rw-r--r-- 1 bind bind 666 Jul 29 22:51 named.conf.options
drwxr-sr-x 2 bind bind 4.0K Aug 6 03:57 primary/
-rw-r----- 1 root bind 77 Mar 19 02:57 rndc.key
-rw-r--r-- 1 bind bind 1.3K Aug 6 03:07 zones.rfc1918
ls -lah /etc/bind/primary/
total 20K
drwxr-sr-x 2 bind bind 4.0K Aug 6 03:57 .
drwxr-sr-x 3 bind bind 4.0K Aug 6 14:41 ..
-rw-r--r-- 1 bind bind 356 Jul 30 00:45 example.com
Run Code Online (Sandbox Code Playgroud)
小智 8
我在 Ubuntu 服务器上遇到了几乎完全相同的问题,结果是两个问题:
(1) 服装店
我不知道 Debian 是否也是如此,但在 Ubuntubind9
上运行时启用了 apparmor。这意味着它只允许写入某些地方。地点列在 中/etc/apparmor.d/usr.sbin.named
,通常建议留在这些目录中。您可以安装该apparmor-utils
软件包并(暂时)禁用 apparmor 以查看是否会导致您的问题:
sudo aa-status
Run Code Online (Sandbox Code Playgroud)
应显示/usr/sbin/named
在强制配置文件列表中。然后运行
sudo aa-complain /usr/sbin/named
Run Code Online (Sandbox Code Playgroud)
将其置于抱怨模式。
(2)区域文件
几乎没有手册/教程提到这一点,但 bind9 期望(预先)存在的区域文件正常工作。该end of file
错误可能是由一个事实,即区域文件不存在(造成的/etc/bind/primary/example.com
,并/etc/bind/primary/sub.example.com
在你的例子)。您可以简单地创建一个这样的:
echo "; DO NOT EDIT MANUALLY - use the \"nsupdate\" utility to prevent data loss
;
\$ORIGIN example.com.
\$TTL 86400 ; 1 day
@ IN SOA ns1.example.com. hostmaster.example.com. (
2009074711 ; serial
7200 ; refresh (2 hours)
300 ; retry (5 minutes)
604800 ; expire (1 week)
60 ; minimum (1 minute)
)
IN NS ns1.example.com.
ns1 IN A <IP of your bind server>" | sudo -u bind tee /etc/bind/primary/example.com
Run Code Online (Sandbox Code Playgroud)
小智 6
在更改存储区域文件的位置之前,我遇到了非常相似的问题。
绑定具有写入权限/var/cache/bind
,但您的区域文件存储在/etc/bind/...
. Bind 当前无权写入 中的文件/etc/bind/...
,因此您需要更新 Bind 的权限或将区域文件存储在 Bind 具有适当权限的目录中。我将介绍将区域文件移动到推荐用于动态区域 ( /var/lib/bind/
)的目录的简单步骤。
移动区域文件mv
(可能需要以 root 身份执行)
mv /etc/bind/primary/example.com /var/lib/bind/primary/
mv /etc/bind/primary/sub.example.com /var/lib/bind/primary/
Run Code Online (Sandbox Code Playgroud)更新named.conf
配置中的文件路径。在您的情况下,这意味着更新/etc/bind/named.conf.local
zone "example.com" {
type master;
file "/var/lib/bind/primary/example.com"; //this line changed
//other stuff removed for clarity
};
zone "sub.example.com" {
type master;
file "/var/lib/bind/primary/sub.example.com"; //this line changed
//other stuff removed for clarity
};
Run Code Online (Sandbox Code Playgroud)重启绑定 service bind9 restart
归档时间: |
|
查看次数: |
21112 次 |
最近记录: |