如何使用 ufw 將所有 UDP 流量轉送至 VPN 用戶端 IP

如何使用 ufw 將所有 UDP 流量轉送至 VPN 用戶端 IP

我將 sipgate 與 freepbx 一起使用,並且我已經解決了我認為單向音訊問題的最後一個障礙。

從我讀到的所有內容來看,問題都指向 NAT。我需要轉發所有 UDP 流量IP 192.168.0.2(這是 ppp0 上的 VPN 用戶端 IP,即 freepbx 盒子)。我使用 ufw 作為 VPN 伺服器上的防火牆。

/etc/ufw/before.rules:

*nat

:POSTROUTING ACCEPT [0:0]
# Allow forward traffic to eth0
-A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE

-A PREROUTING -i eth0 -p tcp --dport 5060 -j DNAT --to-destination 192.168.0.2
-A PREROUTING -i eth0 -p udp --dport 5060 -j DNAT --to-destination 192.168.0.2


# Process the NAT table rules
COMMIT

到目前為止,我正在完美地接聽電話,呼叫者可以聽到但我沒有收到任何音訊。

我該如何轉發所有 UDP 流量進入VPN伺服器的ip 192.168.0.2?

更新:

/etc/ufw/sysctl.conf 取消註解:

net/ipv4/ip_forward=1
net/ipv6/conf/default/forwarding=1
net/ipv6/conf/all/forwarding=1

添加:

-A PREROUTING -i eth0 -p udp --dport 1:54000 -j DNAT --to-destination 192.168.0.2

沒有錯誤,但我認為上述規則可能是正確的,因為防火牆啟動沒有錯誤。音訊問題仍然存在,但這與 unix SE 無關。

相關內容