允许 DNS 服务器使用端口 53

允许 DNS 服务器使用端口 53

我正在尝试使用我的 ubuntu 机器作为 DNS 服务器。我已经安装了 bind 9 包。

我正在使用 dig 检查 DNS 服务器。但是我在客户端上收到了 ICMP 类型 3 代码 3 消息。

这是端口不可用的消息。但是端口 53 正在监听 DNS 连接。

这是 UFW 的输出。

root@server:/etc/bind# ufw status
Status: active

To                         Action      From
--                         ------      ----
80                         ALLOW       Anywhere
20/tcp                     ALLOW       Anywhere
21/tcp                     ALLOW       Anywhere
22                         ALLOW       Anywhere
443                        ALLOW       Anywhere
Anywhere                   ALLOW       20.20.20.0/24
20                         ALLOW       Anywhere
514                        ALLOW       Anywhere
Anywhere                   ALLOW       21.21.21.0/24
554                        ALLOW       Anywhere
53                         ALLOW       Anywhere
80 (v6)                    ALLOW       Anywhere (v6)
20/tcp (v6)                ALLOW       Anywhere (v6)
21/tcp (v6)                ALLOW       Anywhere (v6)
22 (v6)                    ALLOW       Anywhere (v6)
443 (v6)                   ALLOW       Anywhere (v6)
20 (v6)                    ALLOW       Anywhere (v6)
514 (v6)                   ALLOW       Anywhere (v6)
554 (v6)                   ALLOW       Anywhere (v6)
53 (v6)                    ALLOW       Anywhere (v6)

20.20.20.0/24 是客户端的子网,我允许来自该子网的所有数据包。

以下是 netstat 的输出:

root@server:/etc/bind# netstat -nlpu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
udp        0      0 0.0.0.0:51139           0.0.0.0:*                           913/avahi-daemon: r
udp     6144      0 127.0.1.1:53            0.0.0.0:*                           1236/dnsmasq
udp        0      0 0.0.0.0:69              0.0.0.0:*                           1427/in.tftpd
udp     2176      0 0.0.0.0:53671           0.0.0.0:*                           1236/dnsmasq
udp        0      0 0.0.0.0:514             0.0.0.0:*                           918/rsyslogd
udp        0      0 0.0.0.0:631             0.0.0.0:*                           1165/cups-browsed
udp    14848      0 0.0.0.0:5353            0.0.0.0:*                           913/avahi-daemon: r
udp6       0      0 :::69                   :::*                                1427/in.tftpd
udp6       0      0 :::45412                :::*                                913/avahi-daemon: r
udp6       0      0 :::514                  :::*                                918/rsyslogd
udp6   17152      0 :::5353                 :::*                                913/avahi-daemon: r

端口 53 正在监听本地主机。这可能是问题所在吗?

编辑 - -

bind9 配置文件设置为在端口 53 上监听远程 IP 地址。

named.conf

// This is the primary configuration file for the BIND DNS server named.
//
// Please read /usr/share/doc/bind9/README.Debian.gz for information on the
// structure of BIND configuration files in Debian, *BEFORE* you customize
// this configuration file.
//
// If you are just adding zones, please do that in /etc/bind/named.conf.local

include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";


forwarders {
                8.8.8.8;
                8.8.4.4;
           };

listen-on port 53 { 127.0.0.1; 21.21.21.1; };

allow-query { 127.0.0.1; 20.20.20.0/24; };

zone "1.168.192.in-addr.arpa" {
        type master;
        file "/etc/bind/db.192";
};
~

谢谢

答案1

你能让 53 端口出去到任何地方吗?
Shell 命令:

sudo ufw allow out 53

相关内容