系统首次启动时,ufw 会阻止所有允许的端口。
如果我禁用 ufw 并再次启用,它们就会开始被允许;
我不明白这个问题,请帮忙。
查看我的配置(参见 1982)
To Action From
-- ------ ----
80 ALLOW Anywhere
443 ALLOW Anywhere
1982/tcp ALLOW Anywhere
1:79/tcp DENY Anywhere
1:79/udp DENY Anywhere
81:442/tcp DENY Anywhere
81:442/udp DENY Anywhere
444:1981/tcp DENY Anywhere
444:1981/udp DENY Anywhere
1983:5431/tcp DENY Anywhere
1983:5431/udp DENY Anywhere
5433:65535/tcp DENY Anywhere
5433:65535/udp DENY Anywhere
5432/tcp ALLOW Anywhere
5432/udp DENY Anywhere
1982/udp ALLOW Anywhere
80 (v6) ALLOW Anywhere (v6)
443 (v6) ALLOW Anywhere (v6)
1982/tcp (v6) ALLOW Anywhere (v6)
1:79/tcp (v6) DENY Anywhere (v6)
1:79/udp (v6) DENY Anywhere (v6)
81:442/tcp (v6) DENY Anywhere (v6)
81:442/udp (v6) DENY Anywhere (v6)
444:1981/tcp (v6) DENY Anywhere (v6)
444:1981/udp (v6) DENY Anywhere (v6)
1982/udp (v6) ALLOW Anywhere (v6)
1983:5431/tcp (v6) DENY Anywhere (v6)
1983:5431/udp (v6) DENY Anywhere (v6)
5433:65535/tcp (v6) DENY Anywhere (v6)
5433:65535/udp (v6) DENY Anywhere (v6)
5432/tcp (v6) ALLOW Anywhere (v6)
5432/udp (v6) DENY Anywhere (v6)
答案1
您是否允许使用 ssh?请执行sudo ufw allow ssh
。您还可以检查以确保 ssh 位于应用程序列表中。请执行sudo ufw app list
。
另外,请确保打开的 ssh 配置文件是 22,而不是 1982。这可能是您被阻止的原因。使用 检查一下sudo ufw app info OpenSSH
。
如果您仍然遇到相同的问题,您可能需要重置 ufw 并重建它。我会尝试逐步缩小范围并隔离任何问题。首先从 ssh 开始,看看是否可以使其正常工作。然后继续执行其他操作。
因此,先执行sudo ufw reset
,然后sudo ufw enable
。然后开始添加规则,sudo ufw allow 1982/tcp
并从那里继续构建。
答案2
实际上,ufw reset 不起作用,我在 ubuntuforums 上找到了这个答案来重置 iptables
https://ubuntuforums.org/showthread.php?t=1381516
##
## set default policies to let everything in
ip6tables --policy INPUT ACCEPT;
ip6tables --policy OUTPUT ACCEPT;
ip6tables --policy FORWARD ACCEPT;
##
## start fresh
ip6tables -Z; # zero counters
ip6tables -F; # flush (delete) rules
ip6tables -X; # delete all extra chains
# IPv4
##
## set default policies to let everything in
iptables --policy INPUT ACCEPT;
iptables --policy OUTPUT ACCEPT;
iptables --policy FORWARD ACCEPT;
##
## start fresh
iptables -Z; # zero counters
iptables -F; # flush (delete) rules
iptables -X; # delete all extra chains