解决 Linux 报错 neighbor table overflow ARP 邻居表溢出修复
排查 Linux 机器连接大子网或数万个容器并发通信时,内核日志报 neighbor table overflow,导致随机局域网断网,分析 ARP/NDP 邻居表三级垃圾回收阈值(gc_thresh)。
问题现象
高密多容器节点上频繁出现内网通信中断,dmesg 输出明确的内核警告:
[ 5120.100] net_ratelimit: 3410 callbacks suppressed
[ 5120.101] neighbor table overflow!
[ 5120.102] neighbor table overflow!
触发根因
- Linux 内核维护的 ARP/NDP 邻居解析表(Neighbor Table)达到了
gc_thresh3绝对上限(默认仅 1024 或 4096); - 节点在局域网内与海量不同 IP 进行并发通信,每一个目标 IP 都必须建立一个 ARP 邻居项缓存;
- 一旦超过硬限制,内核直接拒绝分配新的邻居条目并丢弃所有出站数据包。
解决步骤
大幅度调高 IPv4 与 IPv6 邻居表的三级垃圾回收门限
编辑 /etc/sysctl.d/99-neighbor.conf:
net.ipv4.neigh.default.gc_thresh1 = 2048
net.ipv4.neigh.default.gc_thresh2 = 8192
net.ipv4.neigh.default.gc_thresh3 = 16384
net.ipv6.neigh.default.gc_thresh1 = 2048
net.ipv6.neigh.default.gc_thresh2 = 8192
net.ipv6.neigh.default.gc_thresh3 = 16384
应用内核设置并生效
执行:sysctl -p /etc/sysctl.d/99-neighbor.conf。
紧急情况下清理无用失效邻居项
使用 iproute2 刷新:
ip neigh flush all
验证确认
重新发起大规模跨网通信:
neighbor table overflow 彻底不再出现,节点平稳维持上万条邻居映射,网络通信平滑通畅。


