You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

本地使用nsupdate更新BIND正常,但通过私有IP或远程连接失败的问题求助

本地使用nsupdate更新BIND正常,但通过私有IP或远程连接失败的问题求助

我已经挠头折腾两天了,还是搞不懂为什么想通过nsupdate/RFC2136更新远程BIND服务器一直出问题,本地操作倒是一切正常。

先说说环境:我用的是BIND 9.16.23,运行在内部服务器上,没有开启AppArmor,也没有防火墙。下面是BIND配置里的关键部分:

options {
    directory "/var/cache/named";
    listen-on { any; };
    allow-query { any; };
    recursion no;
    blackhole { acl_bogusnets; };
    // DNSSEC
    dnssec-validation yes;
    // hide version
    version "not provided";
    key-directory "/etc/named/keys";
    auth-nxdomain no;
};

controls {
    inet 192.168.131.21 port 953 allow { any; } keys { "key_ddns"; };
    inet 192.168.131.21 allow { any; } keys { "key_ddns"; };
    inet 127.0.0.1 port 953 allow { 127.0.0.1; } keys { "rndc-key"; };
};

zone "mydomain.com" IN {
    type master;
    file "/var/named/primary/com/mydomain/db.mydomain.com";
    update-policy {
        grant key_ddns name _acme-challenge.www.mydomain.com. txt;
    };
    notify yes;
    dnssec-policy  "default";
    inline-signing yes;
    key-directory  "/var/named/keys";
};

我先把rndc和key_ddns这两个密钥复制到本地文件夹,然后写了一个nsupdate命令脚本add.txt:

server 127.0.0.1
debug yes
zone mydomain.com
update add _acme-challenge.www.mydomain.com. 300 IN TXT "TEST"
show
send

在本地BIND服务器上执行了不同的命令,结果如下:

  • 用nsupdate -k ./rndc.key add.txt或者nsupdate -k ./rndc.key -v add.txt,会得到报错:
    update: info: client @0x7ff7a0636e18 127.0.0.1#49496/key rndc-key: view view_primary_ns: updating zone 'mydomain.com/IN': update failed: rejected by secure update (REFUSED)
    
  • 用nsupdate -k ./key_ddns.key add.txt或者nsupdate -k ./key_ddns.key -v add.txt,能成功添加记录,日志显示:
    update: info: client @0x7ff7a061a0e8 127.0.0.1#37881/key key_ddns: view view_primary_ns: updating zone 'mydomain.com/IN': adding an RR at '_acme-challenge.www.mydomain.com' TXT "TEST"
    

这说明key_ddns密钥是正常工作的,但接下来问题就来了:

如果把add.txt里的server 127.0.0.1改成私有IP192.168.131.21,执行命令会出现两种情况:

  • nsupdate -k ./rndc.key add.txt或者nsupdate -k ./key_ddns.key add.txt:
    nsupdate error: Communication with 192.168.131.21#53 failed: timed out
    
  • nsupdate -k ./rndc.key -v add.txt或者nsupdate -k ./key_ddns.key -v add.txt:
    nsupdate error: Communication with 192.168.131.21#53 failed: unexpected error
    

同时BIND日志里会出现:

general: error: Accepting TCP connection failed: connection refused
general: error: TCP connection failed: connection refused

后来我又尝试把add.txt里的服务器改成192.168.131.21 953,结果还是不行:

  • 不带-v的命令依旧超时,带-v的命令还是报“unexpected error”
  • BIND日志里变成了:
    general: error: invalid command from 192.168.131.21#39997: out of range
    

我现在完全搞不懂为什么用私有IP就没法正常用nsupdate了,有没有大佬能指点一下?

备注:内容来源于stack exchange,提问作者dolomike

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.20 06:59:49