设置Ubuntu 18.04的bond4和RG-5750-LACP网络连接
最编程
2024-02-04 22:24:41
...
Ubuntu 18.04 配置bond4 LACP
###系统环境:Ubuntu 18.04 x2 (电口x2 随便什么物理服务器都行,至少有两个业务网口)
###网络设备:RG-5750-28GT4 x2 锐捷交换机,有更高端的设备最好。
###网络线缆:光纤3米x2 ,网线x5,10G光模块x2
交换机部分:
###1.两台交换机配置堆叠
###2.堆叠配置完成后,创建两个 LACP接口 组。(如果没有两台交换机,用一台SW也是可以的)
4F-5750-1
switch virtual domain 110 #(1-255 默认100) 组合名称:100
switch 1 #(1-9默认 1) 当前物理设备 ID号
switch 1 prioriy 110 #(1-255) 默认为 100 ,越小越优秀
switch 1 description 4F-5705-1-VSU-110-1-110
vsl-prot
port-member interface TenGigabitEthernet 0/31
port-member interface TenGigabitEthernet 0/32
#switch convert mode virtual #切换单机模式或者 VSU
Convert mode will backup and delete config file, and reload the switch. Are you sure to continue[yes/no]:y
转换模式将备份和删除配置文件,并重新加载交换机。你确定要继续[yes/no]:y
————————————————————————————————————————————————————————————————————————
4F-5750-2
switch virtual domain 110 #(1-255 默认100)
switch 2 #(1-9默认 1)
switch 2 prioriy 120 #(1-255)
switch 2 description 4F-5705-1-VSU-110-2-120
vsl-prot
port-member interface TenGigabitEthernet 0/31
port-member interface TenGigabitEthernet 0/32
#switch convert mode virtual #切换单机模式或者 VSU
Convert mode will backup and delete config file, and reload the switch. Are you sure to continue[yes/no]:y
转换模式将备份和删除配置文件,并重新加载交换机。你确定要继续[yes/no]:y
——————————————————————————————————————————————————————————————
交换机部分:
配置LACP 动态链路聚合:
Aggregateport = AP = 链路聚合
SwitchA# configure terminal
SwitchA(config)# interface range GigabitEthernet 1/0/20 , 2/0/20
SwitchA(config-if-range)# port-group 3 mode active
interface range GigabitEthernet 1/0/21 , 2/0/21
port-group 4 mode active
exit
interface Gig 1/0/20
lacp short-timeout
no shutdown
interface Gig 2/0/20
lacp short-timeout
no shutdown
interface Gig 1/0/21
lacp short-timeout
no shutdown
interface Gig 2/0/21
lacp short-timeout
no shutdown
lacp short-timeout # 默认 90秒检查 LACP,这里配置 LACP 3秒快速检查。
————————————————————————————————————————————
服务器配置部分:
1. 安装 ifenslave
#fenslave为一种粘合和分离式的软件,可以将数据包有效的分配到bonding驱动
apt install -y ifenslave
2.确定内核是否加载 bonding
lsmod | grep bonding
modprode bonding # 加入
echo "bonding" >> /etc/modules #添加 bonding 模块
3.配置bond4网卡文件
###注意 YAML 语法这里语法并不是很标准可以去网上找标准一点的,下面中文备注自己删除一下。
root@ubuntu:~# cat /etc/netplan/01-netcfg.yaml
network:
ethernets:
enp7s0: {}
enp8s0: {}
version: 2
renderer: networkd
bonds:
bond4:
addresses: [192.168.0.61/24]
gateway4: 192.168.0.254
nameservers:
addresses: [ 223.5.5.5 ]
interfaces:
- enp7s0
- enp8s0
parameters:
mode: 802.3ad # 模式 bond4 IEEE 802.3ad 链路聚合 LACP
mii-monitor-interval: 100 #监测时间 100ms
lacp-rate: fast
transmit-hash-policy: layer3+4 # 这里 hash 算法选择 3+4 是为让流量平均分发,具体的需要去论坛上面看看。如果使用 layer2 ,可能达不到 聚合的带宽增加的效果。
4.查看 bond模式是否正常:
root@ubuntu:~# cat /proc/net/bonding/bond6
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: IEEE 802.3ad Dynamic link aggregation
Transmit Hash Policy: layer3+4 (1)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
802.3ad info
LACP rate: fast
Min links: 0
Aggregator selection policy (ad_select): stable
System priority: 65535
System MAC address: c6:f0:56:6c:9a:b4
Active Aggregator Info:
Aggregator ID: 1
Number of ports: 2
Actor Key: 9
Partner Key: 4
Partner Mac Address: 80:05:88:f1:9a:26
Slave Interface: enp8s0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 4
Permanent HW addr: 00:13:92:09:05:4d
Slave queue ID: 0
Aggregator ID: 1
Actor Churn State: none
Partner Churn State: none
Actor Churned Count: 1
Partner Churned Count: 3
details actor lacp pdu:
system priority: 65535
system mac address: c6:f0:56:6c:9a:b4
port key: 9
port priority: 255
port number: 1
port state: 63
details partner lacp pdu:
system priority: 4096
system mac address: 80:05:88:f1:9a:26
oper key: 4
port priority: 32768
port number: 53
port state: 63
Slave Interface: enp7s0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 3
Permanent HW addr: 00:13:92:09:05:4c
Slave queue ID: 0
Aggregator ID: 1
Actor Churn State: none
Partner Churn State: none
Actor Churned Count: 3
Partner Churned Count: 3
details actor lacp pdu:
system priority: 65535
system mac address: c6:f0:56:6c:9a:b4
port key: 9
port priority: 255
port number: 2
port state: 63
details partner lacp pdu:
system priority: 4096
system mac address: 80:05:88:f1:9a:26
oper key: 4
port priority: 32768
port number: 21
port state: 63
root@ubuntu:~#
5.查看服务器bond4接口速率是否正确:
root@ubuntu:~# ethtool bond4
Settings for bond4:
Supported ports: [ ]
Supported link modes: Not reported
Supported pause frame use: No
Supports auto-negotiation: No
Supported FEC modes: Not reported
Advertised link modes: Not reported
Advertised pause frame use: No
Advertised auto-negotiation: No
Advertised FEC modes: Not reported
**Speed: 2000Mb/s**
**Duplex: Full**
Port: Other
PHYAD: 0
Transceiver: internal
Auto-negotiation: off
Link detected: yes
6.使用 iperf 工具测试:
iperf -s -p 1234 -i 1
iperf -c 192.168.0.61 -p 1234 -i 1 -P 4 -t 50
speedometer -tx bond4 -rx bond4 # apt install -y speedometer 网卡流量图形化监控工具。
#带宽跑起来后拔掉网线测试,查看链路聚合切换时间大概几秒钟,是否符合要求,两个接口都需要进行插拔测试,以此来验证 bond4 是否可以正常使用。
——————————————————————————————————————————
##其他大佬的配置方式
以下是bond模式为mode4步骤:
在/etc/netplan下面的文件的.yaml文件下修改bond的参数
network:
ethernets:
enp1s0f0:
addresses: [192.168.1.2/27]
gateway4: 192.168.1.1
enp130s0f0: {}
enp130s0f1: {}
version: 2
renderer: networkd
bonds:
bond0:
addresses: [10.1.110.14/24]
interfaces:
- enp130s0f0
- enp130s0f1
parameters:
mode: 802.3ad #模式为mode4
mii-monitor-interval:
lacp-rate: fast
transmit-hash-policy: layer2
network:
bonds:
bond0:
addresses:
- 192.168.123.101/24
gateway4: 192.168.123.1
interfaces:
- enp74s0f0
- enp74s0f1
nameservers:
addresses:
- 223.5.5.5
parameters:
mode: balance-alb
ethernets:
enp74s0f0: {}
enp74s0f1: {}
version: 2
————————————————
版权声明:本文为****博主「TimeK」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.****.net/a1561386524/article/details/106681394/
##参考连接:
https://blog.51cto.com/alanwu/1095566
https://www.cnblogs.com/kaishirenshi/p/10245228.html
https://halysl.github.io/2020/01/08/Linux-bond-%E9%85%8D%E7%BD%AE/
https://help.ubuntu.com/community/UbuntuBonding/