bash
ping -c 5 example.com
bash
mtr --report example.com
bash
ss -tulnp
bash
iftop -i eth0
bash
tcpdump -i eth0 -w capture.pcap
bash
# 服务端
iperf -s
# 客户端
iperf -c server_ip
bash
ip link show eth0
bash
ip link set eth0 mtu 1500
bash
sysctl -w net.ipv4.tcp_window_scaling=1
sysctl -w net.core.rmem_max=16777216
sysctl -w net.core.wmem_max=16777216
bash
sysctl -w net.ipv4.tcp_fastopen=3
bash
ethtool -g eth0
ethtool -G eth0 rx 4096 tx 4096
bash
tc qdisc add dev eth0 root fq
bash
ulimit -n
sysctl -w fs.file-max=100000
bash
sysctl -w net.netfilter.nf_conntrack_max=1000000
bash
ethtool eth0
bash
ethtool -L eth0 combined 8
# 增加本地端口范围
sysctl -w net.ipv4.ip_local_port_range="1024 65535"
# 启用TCP时间戳
sysctl -w net.ipv4.tcp_timestamps=1
# 减少TIME_WAIT状态时间
sysctl -w net.ipv4.tcp_fin_timeout=30
# 启用TCP复用
sysctl -w net.ipv4.tcp_tw_reuse=1
bash
apt install irqbalance
systemctl enable --now irqbalance
bash
for irq in $(grep eth0 /proc/interrupts | awk '{print $1}' | sed 's/://'); do
echo 1 > /proc/irq/$irq/smp_affinity
done
通过以上方法综合诊断和优化,可以有效解决Linux系统中的网络阻塞和延迟问题。