實時查看網絡接口丟包統計
ip -s link show <接口名>
或 ethtool -S <接口名>
查看 rx_dropped
(接收丟包)、tx_dropped
(發送丟包)等指標。nload
、iftop
工具實時監控流量,判斷是否因高負載導致丟包。系統日志分析
/var/log/syslog
、/var/log/messages
或 journalctl -k
,搜索 dropped
、errors
等關鍵詞,定位內核或驅動報錯。抓包分析
tcpdump
抓取數據包,分析是否存在異常丟包(如特定端口或協議丟包)。定位丟包層級
ethtool -S
檢查網卡硬件錯誤(如 rx_fifo_errors
、collision
),確認是否為網線、交換機或網卡硬件故障。ip -s link
查看 IP 層丟包,結合 netstat -s
分析 TCP/UDP 協議棧問題(如重傳、擁塞)。ss -s
查看套接字狀態,判斷是否因應用連接數過多或超時導致丟包。排查系統配置與資源
iptables
/firewalld
)是否誤攔截流量,開啟日志記錄后分析丟包規則。sar
監控負載,調整內核參數(如 net.core.rmem_max
)優化緩沖區。高級診斷工具
dropwatch
或 ftrace
跟蹤內核丟包點,定位具體丟包函數。eBPF
工具(如 bpftrace
)動態分析網絡棧行為,精準定位丟包邏輯。工具 | 用途 | 示例命令 |
---|---|---|
ip/ethtool |
查看接口與硬件統計 | ip -s link show eth0 ethtool -S eth0 |
tcpdump |
抓包分析丟包細節 | tcpdump -i eth0 -n |
nload/iftop |
實時流量監控 | nload iftop -i eth0 |
journalctl |
查看內核與系統日志 | `journalctl -k |
mtr |
路徑丟包分析 | mtr -c 100 target_ip |
通過以上方法,可系統性定位 Linux 丟包問題,從硬件、內核、網絡到應用層逐步排查。