fangpsh's blog

再次踩到r8169的坑

有一台Linux机器,双网卡,网卡1(板载的千兆 Realtek RTL8111/8168/8411)接内网,网卡2(PCIE扩展,也是千兆Realtek RTL8111/8168/8411)接特定WAN出口,盘路一个IP。跑了几天,发现速度特别慢,压在500KB/s 以下。

  1. ethtool 看网卡速度都是千兆,没降速;看端口没跑满;
  2. 关闭网卡1,流量直接全部走网卡2,现象依旧;
  3. 长ping,不丢包;
  4. 使用其他机器同wan出口,测速,正常,排除出口问题;
  5. 移除所有策略路由和防火墙规则,现象依旧;
  6. 开始怀疑是网卡驱动问题或者网线问题,内网scp 到机器,速度却正常,能上千兆,奇怪了!!
  7. 怀疑是这个便宜的PCIE 网卡2的问题,切换到网卡1,现象依旧;
  8. 按debian 12+ slow internet speed 搜索了一下,看到r8169,死去的记忆又复活了,之前折腾过一台主机,也是默认装了r8169驱动,死活异常,手工搞的r8168 驱动,屏蔽r8169废了半天劲。
  9. 修复:
    1. apt-get install r8168-dkms
    2. echo "blacklist r8169" | sudo tee -a /etc/modprobe.d/blacklist.conf
    3. reboot

反思:

  1. 没想都到debian12 了,这个坑还能存在。
  2. 没想到异常现象是外网限制在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