V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
flowdesign
V2EX  ›  宽带症候群

请教个在 OP 里链路聚合网速不升反降的问题

  •  
  •   flowdesign · 2022-09-06 09:51:04 +08:00 · 4410 次点击
    这是一个创建于 590 天前的主题,其中的信息可能已经有所发展或是发生改变。

    原始参考贴 https://s.v2ex.com/t/822174

    上海电信, 没有在局端开桥接, 自己买了华为的 HN8546Q, 刷回原版固件并补全了 shell, 改成 epon 模式, 光猫端没有做太多的额外设置, 开了 vlan51/85 来实现 IPTV 盒子的使用

    光猫后面用软路由桥接拨号, PVE 宿主+OP 虚拟机, 直通三个网口给了 OP, 没有做 bond 之前单独用 wan1 或者 wan2 拨号测速都是在 900M 上下的速度浮动, 但 bond 之后测速就会掉落到 700-800 之间, 多次测速都是同样的结果, 如果拔掉一根 wan 口的网线在 bond 模式下单线单拨, 速度和普通的单线单拨是基本一致的, 来来回回折腾了很久都没发现问题到底出在哪里, 还望各路神仙给帮忙答疑解惑一下

    PS.1 rc.local 我是这么写的

    modprobe bonding mode=0 miimon=100

    ip link delete bondwan

    ip link add bondwan type bond mode 0

    ip link set eth1 down

    ip link set eth2 down

    ip link set eth1 master bondwan

    ip link set eth2 master bondwan

    ip link set bondwan up

    exit 0

    PS.2 bonding 模式下拨号测速后用 ifconfig 看过 eth1 和 eth2 两个口的流量, 基本一致, 所以应该是按照正常的 bonding 模式在工作的

    37 条回复    2022-09-14 13:00:58 +08:00
    swiftg
        1
    swiftg  
       2022-09-06 13:00:30 +08:00
    ip link set eth1 type bond_slave
    ip link set eth2 type bond_slave
    这两条呢
    lcy630409
        2
    lcy630409  
       2022-09-06 14:00:12 +08:00
    直接在 openwrt 接口中设置 不需要命令行
    lcy630409
        3
    lcy630409  
       2022-09-06 14:02:54 +08:00
    网络 -> 接口 -> 添加新接口-> 新接口的协议 -> 链路聚合(通道绑定)
    之后在 高级设置->从属接口 选择网卡,其他参数默认即可


    这个其实是 lan 口欺骗,有概率会出现 速度反而下降的问题,重新启动一下就好
    flowdesign
        4
    flowdesign  
    OP
       2022-09-06 14:16:15 +08:00
    @swiftg, 我曾经加过这两条, 实际效果一样, 现在我查看 eth1 和 eth2 的状态都是很正常的, eth2 网线拔了, 所以状态为 down, 而且真实 mac 也都显示出来的
    > eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1460 qdisc mq master bondwan state UP mode default group default qlen 1000 link/ether 28:cd:b5:37:49:c7 brd ff:ff:ff:ff:ff:ff
    > eth2: <NO-CARRIER,BROADCAST,MULTICAST,SLAVE,UP,> mtu 1460 qdisc mq master bondwan state DOWN mode default group default qlen 1000 link/ether 28:cd:b5:37:49:c7 brd ff:ff:ff:ff:ff:ff permaddr 28:cd:b5:37:49:c6

    @lcy630409 这种方式我加过, 不过这里有个问题, 这样加出来的接口是一个逻辑接口, 没法再叠加 pppoe 拨号了, 因为 OP 里面把链路聚合和 pppoe 的协议放在一层上面, 是个二选一的方式...
    lcy630409
        5
    lcy630409  
       2022-09-06 14:24:45 +08:00
    @flowdesign 晕 不是啊,先加接口,然后 pppoe 的接口选这个
    lcy630409
        6
    lcy630409  
       2022-09-06 14:25:41 +08:00
    你到 pppoe 的那个接口,设置里的物理设置,看看接口有没有刚那个? 如果你保存成功的话 是肯定有的
    malash
        7
    malash  
       2022-09-06 16:42:23 +08:00
    遇到奇怪的速率问题重启光猫和路由器,亲测
    lxll
        8
    lxll  
       2022-09-06 17:35:52 +08:00 via Android
    这个要看光猫的,有些光猫不支持聚合。

    聚合后测速时你可以看看你的光猫 CPU ,大概率 100%占用。
    flowdesign
        9
    flowdesign  
    OP
       2022-09-06 19:50:22 +08:00
    @lcy630409 重新测试了一下, 和我之前做的一样, 链路聚合产生的是一个逻辑接口, 它不能被另外一个逻辑接口再次调用来执行 pppoe, 如果你曾经成功过的话, 麻烦发个截图让我看看是什么样设置的

    @malash 亲测无数次重启, 然而并没用...

    @lxll 测速时检查光猫 CPU 占用率这个事情倒是没做, 不过按照我理解, 如果光猫物理不支持 bonding 的话, 我绑定的两个 wan 口不可能同时出现数据流量, 并且光猫的两个连接路由器 wan 口的端口数据指示灯是一直闪烁的, 更关键的是 HN8645Q 是很多人亲测支持 balance rr 的
    swiftg
        11
    swiftg  
       2022-09-06 20:22:11 +08:00
    以下是我以前成功运行半年的配置
    opkg update
    opkg install kmod-bonding luci-proto-bonding proto-bonding
    ip link add bond0 type bond mode balance-r

    cat /etc/rc.local

    ip link set eth1 type bond_slave
    ip link set eth2 type bond_slave
    ip link set eth1 master bond0
    ip link set eth2 master bond0
    ip link set bond0 up
    ifconfig eth1 down
    ifconfig eth2 down
    sleep 1
    ifconfig eth1 up
    ifconfig eth2 up

    然后 luci 界面,宽带 pppoe 拨号连接里的网卡选择 bond0
    swiftg
        12
    swiftg  
       2022-09-06 20:24:00 +08:00
    记得配置 bond 后网卡灯不闪,把 eth1 eth2 重启下就正常。每次软路由重启都必须这一步
    swiftg
        13
    swiftg  
       2022-09-06 20:26:51 +08:00
    忘了说我是官方原版的 OpenWrt 21.02 ,硬件是 R86S ,聚合的是两个英特尔 I225 2.5G 口
    swiftg
        14
    swiftg  
       2022-09-06 20:31:25 +08:00
    还有个操作忘了说,我还编辑 /etc/config/network 给 pppoe 拨号的接口手动指定了 mac 地址,这个 luci 界面改不了

    nano /etc/config/network

    config interface 'cmcc'
    option proto 'pppoe'
    option username 'xxx'
    option password 'xxx'
    option metric '5'
    option peerdns '0'
    option ipv6 'auto'
    option macaddr 'xx:xx:xx:xx:xx:xx'
    option mtu '1500'
    option device 'bond0'
    flowdesign
        15
    flowdesign  
    OP
       2022-09-06 21:03:23 +08:00
    @lcy630409 多谢辛苦帮我录屏, 我刚刚又捣鼓了一阵, 并没有什么特殊操作, 然后突然就可以用 wan 口绑定新增加的这个 bond 口来 pppoe 拨号了, 然而坑爹的事情在于, 这种拨号测速直接变成了只有 20M...而且 ifconfig 看到 eth1 和 eth2 口的数据流量都是被放大无数倍, 我重启路由然后就打开测速网页测两次, wan 口显示流量大概是几百兆, eth1 和 eth2 都是已经到了 10G+的状态, 为了家庭和谐, 先暂时改成了单线单拨, 回头再仔细研究一下到底问题是什么...

    @swiftg 你的这个设置跟我之前曾经尝试的是一样的, 我唯一没做的就是指定 mac 地址, 但按理说这个不影响测速才对, 感觉还是没有找到主因是什么
    lcy630409
        16
    lcy630409  
       2022-09-06 21:50:55 +08:00
    @flowdesign
    大概率是你的光猫没有到位,导致了环路 网络风暴了
    最好用原版固件,不要自己补全
    malash
        17
    malash  
       2022-09-06 23:36:47 +08:00
    原版固件没有问题,检查一下光猫的设置——LAN 配置——二 /三层口配置,确保所有口都勾选上了了。以及检查一下 WAN 配置里不需要绑定任何接口

    https://user-images.githubusercontent.com/1812118/188676529-1732df36-c0c3-483e-a2ae-a6adffe19e34.png
    yujincheng08
        18
    yujincheng08  
       2022-09-07 11:38:46 +08:00
    mode0 的 bond 需要对端交换机兼容的,这个光猫支持设置 mode0 的 bond 的吗?
    flowdesign
        19
    flowdesign  
    OP
       2022-09-07 13:58:06 +08:00
    @lcy630409 我也觉得是环路风暴了, 关键就是产生的原因是什么? 通过 luci 增加的 bonding 口和我通过 rc.local 增加的 bonding 口是两次操作的唯一区别, 通过 luci 来增加的会写入到 etc/network 里面, 但是 rc.local 的就不会, 对 OP 没那么深入的了解, 还要花点时间研究一下才行, OP 固件本身的原因我觉得不太大, bonding 本身需要的插件也都是需要手工安装的
    @malash 多谢提醒, 没记错之前我把桥接 wan 口绑定了所有的 lan 口, 回头去解绑了试试看
    @yujincheng08 必须啊, 除非我被各处传播的信息给骗了, 我获取的信息特别指明华为带 Q 的光猫路由器都支持 balance rr 模式的, 8546Q 属于性价比比较高的一款
    lcy630409
        20
    lcy630409  
       2022-09-07 14:51:08 +08:00
    @flowdesign
    我买的 hn8145q 电信 epon
    openwrt 和 ikuai 可以叠加
    yujincheng08
        21
    yujincheng08  
       2022-09-07 15:46:20 +08:00
    @flowdesign

    > 光猫端没有做太多的额外设置

    那你光猫设置聚合了吗?我没看你说设置了。
    malash
        22
    malash  
       2022-09-08 00:07:10 +08:00
    着重看一下“二 /三层口配置”,我记得原厂固件默认没有勾选这几项,而运营商的固件都默认开启,是一个坑
    flowdesign
        23
    flowdesign  
    OP
       2022-09-08 08:25:04 +08:00
    @lcy630409 环路风暴没解决, 依然找不到原因, 逐渐陷入绝望中...
    @malash 看了光猫设置, 二 /三层口配置都勾选了, 然后桥接 wan 口也没有绑定任何的 lan 口
    @yujincheng08 光猫不需要对聚合做额外设置吧, 我也似乎没找到哪里有设置的

    P.S V2 账号设置里的屏蔽搜索引擎并没有用嘛, 放狗搜 8546 聚合, 我的帖子都要上热搜了...
    yujincheng08
        24
    yujincheng08  
       2022-09-08 09:08:50 +08:00
    @flowdesign 光猫需要设置聚合的,bond 0 聚合就是要求两端都配置 bond 不然会坏掉(看下面的 kernel 文档)。你的问题看起来就是光猫没设置 bond 。我估计是需要用 telnet 之类的设置 bond 。所谓网上说的支持 bond 我估计是自带的 kernel 支持,但是没有 web ui 。

    https://www.kernel.org/doc/Documentation/networking/bonding.txt

    The balance-rr, balance-xor and broadcast modes generally
    require that the switch have the appropriate ports grouped together.
    The nomenclature for such a group differs between switches, it may be
    called an "etherchannel" (as in the Cisco example, above), a "trunk
    group" or some other similar variation. For these modes, each switch
    will also have its own configuration options for the switch's transmit
    policy to the bond. Typical choices include XOR of either the MAC or
    IP addresses. The transmit policy of the two peers does not need to
    match. For these three modes, the bonding mode really selects a
    transmit policy for an EtherChannel group; all three will interoperate
    with another EtherChannel group.
    flowdesign
        25
    flowdesign  
    OP
       2022-09-08 09:43:37 +08:00
    @yujincheng08 刚刚又搜了一大圈, 看到一个帖子提到华为光猫固件没有对应的 bonding 内核的问题 <https://www.right.com.cn/forum/thread-4036246-1-1.html> , 今天回去继续研究一下看看, 如果真的是固件没有内核的话, 我要么放弃 bonding, 要么换光猫了
    malash
        26
    malash  
       2022-09-08 11:07:09 +08:00
    Q 结尾的光猫内核里是不需要 bonding 支持的,这几款的交换芯片本身就支持链路聚合,因此无需额外配置就能直接使用,参见 https://www.v2ex.com/t/822174#r_11177803

    相反,OpenWRT 需要内核开启 bonding 以支持链路聚合,原理上使用的是“软”聚合。

    你可以在 OpenWRT 上跑一下 dmesg | grep bond 和 cat /etc/config/network 然后贴一下结果看看吗?(后者注意隐藏 PPPOE 账号密码等信息)
    yujincheng08
        27
    yujincheng08  
       2022-09-08 11:09:03 +08:00
    @flowdesign 真的想 bond 可以尝试用 mode6 ,这不需要对端支持。
    swiftg
        28
    swiftg  
       2022-09-08 14:57:17 +08:00
    HN8546Q 聚合成功,登陆光猫看了的,没有 bonding.ko
    flowdesign
        29
    flowdesign  
    OP
       2022-09-08 18:53:41 +08:00
    @malash
    dmesg | grep bond 的结果如下
    [ 18.382320] 8021q: adding VLAN 0 to HW filter on device bondwan
    [ 18.384502] br-IPTV51: port 4(bondwan.51) entered blocking state
    [ 18.385421] br-IPTV51: port 4(bondwan.51) entered disabled state
    [ 18.386689] device bondwan.51 entered promiscuous mode
    [ 18.387423] device bondwan entered promiscuous mode
    [ 18.438353] br-IPTV85: port 4(bondwan.85) entered blocking state
    [ 18.439293] br-IPTV85: port 4(bondwan.85) entered disabled state
    [ 18.440374] device bondwan.85 entered promiscuous mode
    [ 18.572613] bondwan: (slave eth1): Enslaving as an active interface with an u p link
    [ 18.573799] IPv6: ADDRCONF(NETDEV_CHANGE): bondwan: link becomes ready
    [ 18.574914] br-IPTV51: port 4(bondwan.51) entered blocking state
    [ 18.575883] br-IPTV51: port 4(bondwan.51) entered forwarding state
    [ 18.579326] br-IPTV85: port 4(bondwan.85) entered blocking state
    [ 18.580288] br-IPTV85: port 4(bondwan.85) entered forwarding state
    [ 18.685858] bondwan: (slave eth2): Enslaving as an active interface with an u p link
    [ 102.968787] device bondwan.51 left promiscuous mode
    [ 102.969839] br-IPTV51: port 4(bondwan.51) entered disabled state
    [ 103.020110] device bondwan.85 left promiscuous mode
    [ 103.021104] device bondwan left promiscuous mode
    [ 103.022287] br-IPTV85: port 4(bondwan.85) entered disabled state
    [ 103.236200] 8021q: adding VLAN 0 to HW filter on device bondwan
    [ 103.240105] br-IPTV51: port 4(bondwan.51) entered blocking state
    [ 103.241799] br-IPTV51: port 4(bondwan.51) entered disabled state
    [ 103.243575] device bondwan.51 entered promiscuous mode
    [ 103.244972] device bondwan entered promiscuous mode
    [ 103.246447] br-IPTV51: port 4(bondwan.51) entered blocking state

    network config 是这样的

    config interface 'loopback'
    option ifname 'lo'
    option proto 'static'
    option ipaddr '127.0.0.1'
    option netmask '255.0.0.0'

    config globals 'globals'
    option packet_steering '1'

    config interface 'lan'
    option type 'bridge'
    option proto 'static'
    option netmask '255.255.255.0'
    option delegate '0'
    option _orig_ifname 'eth0'
    option _orig_bridge 'true'
    option ifname 'eth0'
    option ipaddr '192.168.1.111'

    config interface 'vpn0'
    option ifname 'tun0'
    option proto 'none'

    config interface 'docker'
    option ifname 'docker0'
    option proto 'none'
    option auto '0'

    config device
    option type 'bridge'
    option name 'docker0'

    config interface 'ipsec_server'
    option ifname 'ipsec0'
    option device 'ipsec0'
    option proto 'static'
    option ipaddr '192.168.100.1'
    option netmask '255.255.255.0'

    config interface 'wan'
    option proto 'pppoe'
    option username '马赛克'
    option password '马赛克'
    option keepalive '5 5'
    option mtu '1460'
    option ipv6 '0'
    option delegate '0'
    option _orig_ifname 'bondwan'
    option _orig_bridge 'false'
    option metric '40'
    option ifname 'bondwan'

    config interface 'IPTV51'
    option type 'bridge'
    option proto 'none'
    option ifname 'bondwan.51 eth0.51 eth1.51 eth2.51'
    option auto '1'
    option delegate '0'

    config interface 'IPTV85'
    option type 'bridge'
    option proto 'none'
    option ifname 'bondwan.85 eth0.85 eth1.85 eth2.85'
    option auto '1'
    option delegate '0'

    有一些 OP 自己加的 IPSec, VPN 啥的接口, 我也懒得删就留着了, 主要用的就是 wan, lan, 外加为了 IPTV 加出来的一堆带 vlan tag 的接口, 反正我自己看 log 就是压根没看出什么不妥的地方... 我刚刚是重启了路由器以后重新加载 rc.local 增加的 bonding, 然后这个 bonding 拨号成功后我测速依然不出意料地只有 700 多 M, 再然后它就突然断线, 看了一眼 eth2 口不亮了, 我暂时没空研究, 拔掉网线现在暂时还有网络来回帖, 晚上不敢再折腾下去, 不然要被赶出家门


    @swiftg 你这句话让我很伤心啊
    swiftg
        30
    swiftg  
       2022-09-08 20:01:48 +08:00
    有可能是 mtu 的问题?我看你 pppoe 的 mtu 设置为 1460 ,我的是 1500 ,试着改下不同的值?

    另外试试这个命令
    iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu

    我以前有些 https 网站有问题,用这个命令解决的
    malash
        31
    malash  
       2022-09-08 23:43:30 +08:00
    @flowdesign 我看了一下,感觉是有些问题。

    首先 bonding 的配置你按照 3 楼说的来,不需要任何开机脚本,直接网页操作最简单。最终效果如下:

    https://user-images.githubusercontent.com/1812118/189165482-057ef731-9b70-4c90-8ec2-bbaa375fc812.png
    https://user-images.githubusercontent.com/1812118/189165611-6b3d57d8-6364-44e0-aa8f-b114acb13b96.png
    https://user-images.githubusercontent.com/1812118/189165934-1e06d221-4e47-4f16-a6a2-79b3be11c417.png

    然后你几个 IPTV 接口建议先删掉或者禁用,再或者只绑定一个 eth0.*。我也遇到了类似的的问题——链路聚合和 VLAN 不太兼容,因此对于需要 VLAN 的情况只能绑定原始的接口,用 bondwan.*大概是不生效的。

    你配置里 option ifname 'bondwan.51 eth0.51 eth1.51 eth2.51' 显然是不对的,这样会把聚合和未聚合的给桥接在一起了,有可能是造成网络风暴的原因。
    malash
        32
    malash  
       2022-09-08 23:45:43 +08:00
    这是我的 dmesg 输出,应该非常简洁的:

    root@OpenWrt:~# dmesg | grep bond
    [ 10.166536] bonding: bonding-bond is being created...
    [ 10.199854] 8021q: adding VLAN 0 to HW filter on device bonding-bond
    [ 11.296123] bonding-bond: (slave eth1): Enslaving as an active interface with an up link
    [ 11.297601] IPv6: ADDRCONF(NETDEV_CHANGE): bonding-bond: link becomes ready
    [ 12.386727] bonding-bond: (slave eth2): Enslaving as an active interface with an up link
    malash
        33
    malash  
       2022-09-08 23:51:35 +08:00
    “HN8546Q 聚合成功,登陆光猫看了的,没有 bonding.ko”

    不至于伤心啦,其实本质原因就是光猫走了硬交换,好处是性能比较好,坏处是支持的模式比较少,而且(猜测) VLAN 支持有问题。相反软路由这边走的都是软交换,对 CPU 占用会大一些。

    忘了问你用的什么路由器了,是 x86 还是硬路由刷的?硬路由可能会有 CPU 性能不够的问题,建议用 x86
    ttvast
        34
    ttvast  
       2022-09-09 18:17:46 +08:00
    根据我多次测试下来的,找到了一个最稳妥的多端口方式就是 iptables 的-m statistic --mode nth
    用光猫拨号,路由器多个 wan 口接光猫,然后每个 lan 口分配一个地址做 nat 的负载均衡。完全不需要光猫的支持。
    flowdesign
        35
    flowdesign  
    OP
       2022-09-12 18:10:23 +08:00
    @malash
    dmesg | grep bond 的结果因为混杂了很多 vlan tag 的软件接口,去掉那些以后跟 wan 口有关的看起来正常
    root@OpenWrt:~# dmesg | grep bond
    [ 18.209568] 8021q: adding VLAN 0 to HW filter on device bondwan
    [ 18.336374] bondwan: (slave eth1): Enslaving as an active interface with an up link
    [ 18.340263] device bondwan entered promiscuous mode
    [ 18.422994] bondwan: (slave eth2): Enslaving as an active interface with an up link
    我的路由是 J4125 安装了 PVE 宿主,OP 是 PVE 里面的一个虚拟机,给分配了 2G 内存,日常负载我看过很低,测速的时候也就是不到 50%的 cpu 占用

    回头再按你的建议把 vlan tag 去掉再看看,但是为了实现 IPTV 任意网口使用,还是要想个办法把 vlan51 、85 都加上的...
    malash
        36
    malash  
       2022-09-12 23:56:24 +08:00
    @ttvast 有点意思,这样的话能实现单线程突破千兆吗?
    ttvast
        37
    ttvast  
       2022-09-14 13:00:58 +08:00
    @malash 单线程肯定不行,不过有这必要吗?服务器端一般也不会让你单线程跑到千兆吧。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5265 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 07:48 · PVG 15:48 · LAX 00:48 · JFK 03:48
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.