Linux發不出分片包的問題分析

今日有個網絡攻擊模擬需求,要打分片的ip包,程序寫好了,在開發機上驗證也沒問題,而後部署到沙盒環境以後不行,就是發不出來數據包,而不分片的數據包可以正常發送,定位過程以下網絡

1.對比了兩臺機器/proc/sys/net/ipv4下的ip相關參數的值,都同樣,忽略了由於ipfrag相關設置帶來的影響。ui

2. 查看dmesg、/var/log/messages,沒有什麼異常的日誌。spa

3. 查看netstat -s日誌

Ip:
226610920001 total packets received
957 with invalid addresses
0 forwarded
0 incoming packets discarded
226610067704 incoming packets delivered
588767879431 requests sent out
20609816 outgoing packets dropped
43646 dropped because of missing route
42 fragments dropped after timeout
353567514 reassemblies required 42 packet reassembles failed

其中飄紅的這同樣,按照50w/s的速率遞增,大體知道了是內核丟掉了數據包,猜想的緣由是:內核設定了重組數據包,等待發送來的後續數據包,一直沒等到。code

4. 搞網卡的參數blog

ethtool -K xgbe0 tso off
ethtool -K xgbe0 gso off
ethtool -K xgbe0 gro off
ethtool -K xgbe0 lrf off

5. 以後數據包能發出來10s不到,數據包又發不出來了。ip

6. 考慮是內核相關的東西,查看各內核模塊發現有nf_defrag_ipv4模塊,手工去掉全部相關模塊開發

rmmod  iptable_nat  nf_nat
rmmod nf_conntrack_ipv4 nf_conntrack  nf_defrag_ipv4
rmmod iptable_filter  ip_queue nfnetlink iptable_mangle ip_tables x_tables

7.搞定部署

 

總結:解決問題的過程當中並無徹底搞清楚各類現象的根本緣由以及牽涉到知識的根本,須要繼續補充requests

相關文章
相關標籤/搜索