當資料包透過熱點傳輸時,為什麼 Linux 不傳送資料到應用程式?

當資料包透過熱點傳輸時,為什麼 Linux 不傳送資料到應用程式?

我的目標是使用 MITM 代理攔截流量。為此,我將筆記型電腦配置為託管 Wi-Fi 熱點,連接智慧型手機,啟動代理,並將智慧型手機配置為使用我的筆記型電腦作為該 Wi-Fi 網路上的代理。

主機 IP 為10.42.0.1,客戶端 IP 為10.42.0.2。代理正在偵聽連接埠 8080,任何介面。它正確顯示netstat,我可以netcat從本地主機存取它。 Android 手機配置為透過10.42.0.1連接埠 8080 進行代理。

透過電話,我可以 ping 通10.42.0.1;在 Wireshark 中,我看到回顯請求傳入並發出回應。

但是,當電話發送 TCP 或 UDP 封包時,系統不會回應。當使用 netcat 在 UDP 上偵聽熱點並從手機傳送 UDP 資料時,資料不會傳遞到 netcat。我可以在 Wireshark 中看到帶有資料的資料包傳入,但終端仍為空白。當監聽 TCP 時,我可以在 Wireshark 中看到來自電話的 SYN 封包,但它從未被確認(沒有 SYN+ACK 回應)。

熱點 ( 10.42.0.1) 顯然具有 ARP,且回傳路由或 ICMP 回顯回應不會出去。沒有安裝主機防火牆。重啟後問題依然存在。

可能是什麼問題呢?

答案1

在寫問題時,我意識到,雖然我知道它不可能是防火牆,因為我沒有安裝防火牆,而且它不可能是iptables,因為它們在重新啟動後不會持續存在,但我意識到我實際上並沒有檢查這一點沒有設定 iptables 規則。

# iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination
ACCEPT     udp  --  anywhere             anywhere             udp dpt:bootps
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:bootps
ACCEPT     udp  --  anywhere             anywhere             udp dpt:domain
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:domain
DROP       all  --  anywhere             anywhere             state INVALID
ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere
ACCEPT     icmp --  anywhere             anywhere
ACCEPT     udp  --  anywhere             anywhere             udp dpt:isakmp
ACCEPT     esp  --  anywhere             anywhere
ACCEPT     ah   --  anywhere             anywhere
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:8528

事實證明,有某種東西,可能是 NetworkManager 以其無限的智慧,決定為我們添加一些規則,很高興意外地提供了防火牆。

解決方法是取消一些規則並重設預設策略:

# iptables -L --line-numbers
Chain INPUT (policy DROP)
num  target     prot opt source               destination
1    ACCEPT     udp  --  anywhere             anywhere             udp dpt:bootps
2    ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:bootps
3    ACCEPT     udp  --  anywhere             anywhere             udp dpt:domain
4    ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:domain
5    DROP       all  --  anywhere             anywhere             state INVALID
# iptables -D INPUT 5
# iptables --policy INPUT ACCEPT

我在 NetworkManager 文件甚至原始程式碼中找不到任何對此的引用。我不知道這個連接埠 8528 是什麼,它似乎默認允許(它沒有在任何地方註冊或引用),並且我無法快速找到調用 iptables 的相關程式碼,或者找到任何相關設定來阻止它對防火牆進行防火牆處理聯繫。也許 NetworkManager 會呼叫隨後安裝此軟體的其他軟體?

相關內容