只有當 B 先發送資料包時,A 和 B 之間的 UDP 才有效

只有當 B 先發送資料包時,A 和 B 之間的 UDP 才有效

我有兩台獨立的 Linux 電腦 A 和 B,需要透過連接埠 3000 上的 UDP 進行通訊。

由於某種原因,B 能夠從 A 接收 UDP 封包的唯一方法是 B 先向 A 發送封包。

工作案例:

# Computer A Listens (IP 1.2.3.4)
netcat -ul 3000

# Computer B Initiates
netcat -u 1.2.3.4 3000

在上面的情況下,兩個透過netcat“連接”,我可以雙向發送和接收資料。這讓我相信這不是連接埠轉送或路由問題。

破損案例:

# Computer B Listens (IP 5.6.7.8)
netcat -ul 3000

# Computer A Initiates
netcat -u 5.6.7.8 3000

在這種損壞的情況下,兩者無法透過 netcat“連接”,我無法在任一端點之間發送任何資料。

我還嘗試使用直接資料包發送工具在 A 和 B 之間發送 UDP 資料包。

我不知道為什麼會發生這樣的事情,尤其是對於 UDP。有什麼想法可能導致這個問題嗎?

編輯

檢查了 B 上的連接埠轉送。

$iptables -L -t nat
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         
DNAT       udp  --  anywhere             anywhere            udp dpt:3000 to:192.168.3.2:3000 

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         
MASQUERADE  0    --  anywhere             anywhere 



$iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     0    --  anywhere             anywhere            state RELATED,ESTABLISHED 
ACCEPT     0    --  anywhere             anywhere                     
ACCEPT     udp  --  anywhere             192.168.3.2         udp dpt:3000 

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination 

我的 iptables 設定中是否缺少某些內容,無法正確轉送 UDP 的任何地方:3000 到 192.168.3.2:3000?

相關內容