我使用 ufw 打开了 5055、8082 和 5013 端口。它显示状态:活动
To Action From
-- ------ ----
Nginx HTTP ALLOW Anywhere
8082 ALLOW Anywhere
5013 ALLOW Anywhere
5055 ALLOW Anywhere
5013/tcp ALLOW Anywhere
5013/udp ALLOW Anywhere
5055/tcp ALLOW Anywhere
5055/udp ALLOW Anywhere
22 ALLOW Anywhere
80 ALLOW Anywhere
8000 ALLOW Anywhere
2021 ALLOW Anywhere
Nginx HTTP (v6) ALLOW Anywhere (v6)
8082 (v6) ALLOW Anywhere (v6)
5013 (v6) ALLOW Anywhere (v6)
5055 (v6) ALLOW Anywhere (v6)
5013/tcp (v6) ALLOW Anywhere (v6)
5013/udp (v6) ALLOW Anywhere (v6)
5055/tcp (v6) ALLOW Anywhere (v6)
5055/udp (v6) ALLOW Anywhere (v6)
22 (v6) ALLOW Anywhere (v6)
80 (v6) ALLOW Anywhere (v6)
8000 (v6) ALLOW Anywhere (v6)
2021 (v6) ALLOW Anywhere (v6)
但是从外部检查端口时它似乎已关闭..任何帮助和建议都将非常有帮助...谢谢!
答案1
打开网络端口意味着有应用程序/进程在该端口上接受连接。ufw
您提供的输出仅表示当有东西试图连接到该端口时防火墙不会干预,并不意味着端口会自动打开。打开端口是应用程序的责任。
考虑以下两个例子:
$ nmap -p 5566 localhost
Starting Nmap 7.70 ( https://nmap.org ) at 2019-03-10 15:06 CST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00021s latency).
PORT STATE SERVICE
5566/tcp closed unknown
Nmap done: 1 IP address (1 host up) scanned in 0.22 seconds
现在如果我启动一个应用程序nc -l 5588
$ nmap -p 8866 localhost
Starting Nmap 7.70 ( https://nmap.org ) at 2019-03-10 15:07 CST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00021s latency).
PORT STATE SERVICE
5566/tcp open unknown
Nmap done: 1 IP address (1 host up) scanned in 0.18 seconds
也可以看看维基百科上关于该主题的文章。