Debian Sniffer性能优化实战指南
一 目标与总体思路
二 采集层优化
sudo tcpdump -i eth0 -w capture.pcap 'tcp port 80'net.core.rmem_max = 134217728net.core.wmem_max = 134217728net.ipv4.tcp_rmem = 4096 87380 134217728net.ipv4.tcp_wmem = 4096 65536 134217728sudo sysctl -p三 存储与分析层优化
sudo tcpdump -i eth0 -w capture_%Y%m%d_%H%M.pcapng -G 3600 -C 100四 监控与调优闭环
五 常见场景与命令清单
| 场景 | 优化要点 | 示例命令 |
|---|---|---|
| 高带宽HTTP流量定位 | 精准端口过滤、增大缓冲、pcapng轮转 | sudo tcpdump -i eth0 -w http_%Y%m%d_%H%M.pcapng -G 600 -C 500 'tcp port 80' -nn |
| 突发丢包排查 | 增大内核/套接字缓冲、iftop+nethogs定位占用、必要时硬件队列检查 | sudo sysctl -w net.core.rmem_max=134217728;sudo iftop -i eth0;sudo nethogs |
| 多核离线解析 | 按文件并行解析、使用tshark | tshark -r capture_20251114_1000.pcapng -q -z io,stat,1 > stats_1000.csv & |
| 10G链路抓包 | 多队列网卡、Jumbo帧一致、驱动队列优化 | sudo ethtool -l eth0;sudo ethtool -s eth0 speed 10000 duplex full autoneg off |
合规与安全提示