如何使用 UFW 允許本地介面上的所有流量?

如何使用 UFW 允許本地介面上的所有流量?

我已經將 Apache 作為另一個 Docker 服務的反向代理來運行。我得到了它的工作,但一旦我啟用 UFW,所有連接都會被阻止,並顯示以下錯誤訊息:

12月29日23:50:23 vps520941核心:[2870586.522706] [UFW BLOCK] IN= OUT=br-xxxxxxxxx SRC=172.24.0.1 DST=172.24.0.xxxxxx SRC=172.24.0.1 DST=172.24.0.xxxxxx SRC=172.24.0.1 DST=172.24.0.xxxxxx SRC=60 TOS 38755 DF協定=TCP SPT=54620 DPT=22300 視窗=292

這是以下結果ifconfig

br-xxxxxxxxx Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx
          inet addr:172.24.0.1  Bcast:172.24.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:22 errors:0 dropped:0 overruns:0 frame:0
          TX packets:34 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1630 (1.6 KB)  TX bytes:2896 (2.8 KB)

以前,我曾嘗試允許網路介面 IP 上的流量,但每次重新啟動時它都會發生變化,因此這不起作用。

我在 ufw 中有這樣的東西:ufw allow in from 172.22.0.0/24 to any port但是當然這不再起作用了,因為介面 IP 現在是 172.24.0.1。

所以我想知道,是否可以告訴UFW允許所有連接,不是基於IP,而是基於網路介面名稱?

答案1

它就在手冊頁中,有許多範例:on <interface>.

考慮:

ufw allow in(or out) on <interface> to any

相關內容