有一台Linux机器,双网卡,网卡1(板载的千兆 Realtek RTL8111/8168/8411)接内网,网卡2(PCIE扩展,也是千兆Realtek RTL8111/8168/8411)接特定WAN出口,盘路一个IP。跑了几天,发现速度特别慢,压在500KB/s 以下。
- ethtool 看网卡速度都是千兆,没降速;看端口没跑满;
- 关闭网卡1,流量直接全部走网卡2,现象依旧;
- 长ping,不丢包;
- 使用其他机器同wan出口,测速,正常,排除出口问题;
- 移除所有策略路由和防火墙规则,现象依旧;
- 开始怀疑是网卡驱动问题或者网线问题,内网scp 到机器,速度却正常,能上千兆,奇怪了!!
- 怀疑是这个便宜的PCIE 网卡2的问题,切换到网卡1,现象依旧;
- 按debian 12+ slow internet speed 搜索了一下,看到r8169,死去的记忆又复活了,之前折腾过一台主机,也是默认装了r8169驱动,死活异常,手工搞的r8168 驱动,屏蔽r8169废了半天劲。
- 修复:
- apt-get install r8168-dkms
- echo "blacklist r8169" | sudo tee -a /etc/modprobe.d/blacklist.conf
- reboot
反思:
- 没想都到debian12 了,这个坑还能存在。
- 没想到异常现象是外网限制在400~500KB以下,内网却正常,奇了怪。
# lshw -C network
*-network
description: Ethernet interface
product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
vendor: Realtek Semiconductor Co., Ltd.
physical id: 0
bus info: pci@0000:03:00.0
logical name: enp3s0
version: 15
serial: 70:...
size: 1Gbit/s
capacity: 1Gbit/s
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress msix bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=r8168 driverversion=8.051.02-NAPI duplex=full ip=192.168... latency=0 link=yes multicast=yes port=twisted pair speed=1Gbit/s
resources: irq:16 ioport:4000(size=256) memory:c2304000-c2304fff memory:c2300000-c2303fff
*-network
description: Ethernet interface
product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
vendor: Realtek Semiconductor Co., Ltd.
physical id: 0
bus info: pci@0000:04:00.0
logical name: enp4s0
version: 15
serial: 00:...
size: 1Gbit/s
capacity: 1Gbit/s
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress msix bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=r8168 driverversion=8.051.02-NAPI duplex=full ip=192.168... latency=0 link=yes multicast=yes port=twisted pair speed=1Gbit/s
resources: irq:17 ioport:3000(size=256) memory:c2204000-c2204fff memory:c2200000-c2203fff
2024-11-22更新:期间重启了一次系统之后,又恢复异常原样了。 搜了一圈,关闭网卡2的TSO 之后,恢复。
> ethtool --show-offload enp3s0 # 查看tso是否开启
> ethtool -K enp3s0 tso off # 关闭tso
> ethtool -K enp3s0 gso off # 顺便关了gso
#持久化,修改/etc/network/interfaces, 添加:
auto enp3s0
iface enp3s0 inet dhcp
metric 100
offload-tso off
offload-gso off