![允许 ufw 规则针对特定端口卷曲本地主机](https://linux22.com/image/120684/%E5%85%81%E8%AE%B8%20ufw%20%E8%A7%84%E5%88%99%E9%92%88%E5%AF%B9%E7%89%B9%E5%AE%9A%E7%AB%AF%E5%8F%A3%E5%8D%B7%E6%9B%B2%E6%9C%AC%E5%9C%B0%E4%B8%BB%E6%9C%BA.png)
我只想curl -if localhost:54321
允许ufw
.我可以从命令行应用什么规则?
我已尝试ufw allow proto tcp from any to any port 54321
并ufw status
显示以下内容:
To Action From
-- ------ ----
54321/tcp ALLOW Anywhere
54321/tcp (v6) ALLOW Anywhere (v6)
但我还是做不到curl -if localhost:54321
。
答案1
知道了:
ufw allow proto tcp from any to any port 54321,54322
ufw allow out proto tcp from any to any port 54321,54322
答案2
从man ufw
:
Allow access to udp 1.2.3.4 port 5469 from 1.2.3.5 port 5469: ufw allow proto udp from 1.2.3.5 port 5469 to 1.2.3.4 port 5469
因此您正在寻找的命令是
ufw allow proto tcp from <ip_source> to <ip_destination> port 54321