温馨提示×

centos dropped为什么丢包

小樊
41
2026-10-09 02:10:03
栏目: 智能运维

在 CentOS(或其他 Linux 系统)上看到 “dropped” 丢包,通常来自 ifconfig、ip -s link、netstat -i、sar -n DEV 或 ethtool -S 等命令。
“dropped” 和 “errors” 不同:errors 是硬件/链路错误,dropped 一般是 内核收到包但决定丢弃。

下面按「最常见 → 较少见」说明原因。


一、最常见原因

1️⃣ 接收队列溢出(Ring Buffer / backlog 满)

高流量或瞬时突发时,网卡或内核缓冲来不及处理。

查看:

ethtool -S eth0 | grep -i drop

常见字段:

  • rx_dropped
  • rx_missed_errors
  • rx_fifo_errors

解决:

# 增大网卡 ring buffer
ethtool -G eth0 rx 4096

# 增大内核 backlog
sysctl -w net.core.netdev_max_backlog=2000

2️⃣ 内核 socket 缓冲区不足(应用处理慢)

常见于:

  • Nginx / Redis / 数据库
  • 高并发短连接

查看:

cat /proc/net/sockstat

或

ss -lnt

解决:

sysctl -w net.core.rmem_max=16777216
sysctl -w net.core.wmem_max=16777216
sysctl -w net.ipv4.tcp_rmem="4096 87380 16777216"
sysctl -w net.ipv4.tcp_wmem="4096 65536 16777216"

3️⃣ 防火墙 / 策略丢弃(iptables / nftables)

被 DROP 的包会计入 dropped。

查看:

iptables -L -v -n
nft list ruleset

常见场景:

  • 限速
  • 防 SYN Flood
  • 白名单策略

4️⃣ 网卡多队列 & CPU 软中断不均衡

单核软中断打满,其他队列空闲。

查看:

cat /proc/interrupts | grep eth
mpstat -P ALL 1

解决:

# 开启 RPS / RFS
sysctl -w net.core.rps_sock_flow_entries=32768

二、系统与配置原因

5️⃣ 网卡 offload 异常

ethtool -k eth0

可尝试关闭:

ethtool -K eth0 gro off
ethtool -K eth0 lro off

6️⃣ MTU / 分片问题

  • MTU 不匹配
  • 中间设备不允许分片

检查:

ip link show
ping -M do -s 1472 <ip>

7️⃣ 虚拟化 / 云环境

  • 宿主机限速
  • vhost-net 队列不足
  • 云厂商安全组丢包

三、快速排查顺序(推荐)

# 1. 看哪一层丢
ip -s link

# 2. 看网卡硬件统计
ethtool -S eth0

# 3. 看系统 socket
cat /proc/net/sockstat

# 4. 看防火墙
iptables -L -v -n

# 5. 看中断
cat /proc/interrupts

四、你可以告诉我

我可以更精确判断:

  1. dropped 出现在 哪个命令
  2. 网卡名(eth0 / ens192)
  3. 是 入方向还是出方向
  4. 是否是 高并发 / 大流量场景
  5. 物理机 / 虚拟机 / 云

我可以直接给你对应的参数和配置。

0 踩