CentOS 7 与 华为交换机 端口汇聚 LACP BONDING

2021-08-19 592 0

服务器型号: Dell R730XD
系统:CentOS Linux release 7.6.1810 (Core)
交换机:华为 S5720S-28X-LI-AC 三层交换机
网卡:BCM5720 1G x4 + Intel X520-2 10G x2

交换机配置

将g0/0/9-12 4个端口组成Eth-Trunk 43`
`将x0/0/1-2 2个端口组成Eth-Trunk 91
<HUAWEI>system  
Enter system view, return user view with Ctrl+Z.
[HUAWEI]int Eth-Trunk 43
[HUAWEI-Eth-Trunk43]mode lacp
[HUAWEI-Eth-Trunk43]lacp timeout fast
[HUAWEI-Eth-Trunk43]undo local-preference enable
[HUAWEI-Eth-Trunk43]quit
[HUAWEI]int g0/0/9
[HUAWEI-GigabitEthernet0/0/9]Eth-Trunk 43
Info: This operation may take a few seconds. Please wait a moment...done.
[HUAWEI]int g0/0/10
[HUAWEI-GigabitEthernet0/0/10]Eth-Trunk 43
Info: This operation may take a few seconds. Please wait a moment...done.
[HUAWEI]int g0/0/11
[HUAWEI-GigabitEthernet0/0/11]Eth-Trunk 43
Info: This operation may take a few seconds. Please wait a moment...done.
[HUAWEI]int g0/0/12
[HUAWEI-GigabitEthernet0/0/12]Eth-Trunk 43
Info: This operation may take a few seconds. Please wait a moment...done.

[HUAWEI]int Eth-Trunk 91
[HUAWEI-Eth-Trunk91]mode lacp
[HUAWEI-Eth-Trunk91]lacp timeout fast
[HUAWEI-Eth-Trunk91]undo local-preference enable
[HUAWEI-Eth-Trunk91]quit
[HUAWEI]int x0/0/1
[HUAWEI-XGigabitEthernet0/0/1]Eth-Trunk 91
Info: This operation may take a few seconds. Please wait a moment...done.
[HUAWEI]int x0/0/2
[HUAWEI-XGigabitEthernet0/0/2]Eth-Trunk 91
Info: This operation may take a few seconds. Please wait a moment...done.

[HUAWEI-XGigabitEthernet0/0/2]display Eth-Trunk 91
[HUAWEI-XGigabitEthernet0/0/2]dis int brief

服务器

BOND0

cat << EOF > /etc/sysconfig/network-scripts/ifcfg-bond0
Type=Bond
DEVICE=bond0
NAME=bond0
BONDING_MASTER=yes
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.1.43
PREFIX=24
GATEWAY=192.168.1.1
DNS1=192.168.1.1
NM_CONTROLLED=no
BONDING_OPTS="mode=4 miimon=100 lacp_rate=1"
EOF

cat << EOF > /etc/sysconfig/network-scripts/ifcfg-em1
TYPE=Ethernet
DEVICE=em1
BOOTPROTO=none
ONBOOT=yes
NM_CONTROLLED=no
IPV6INIT=no
MASTER=bond0
SLAVE=yes
EOF

cat << EOF > /etc/sysconfig/network-scripts/ifcfg-em2
TYPE=Ethernet
DEVICE=em2
BOOTPROTO=none
ONBOOT=yes
NM_CONTROLLED=no
IPV6INIT=no
MASTER=bond0
SLAVE=yes
EOF

cat << EOF > /etc/sysconfig/network-scripts/ifcfg-em3
TYPE=Ethernet
DEVICE=em3
BOOTPROTO=none
ONBOOT=yes
NM_CONTROLLED=no
IPV6INIT=no
MASTER=bond0
SLAVE=yes
EOF

cat << EOF > /etc/sysconfig/network-scripts/ifcfg-em4
TYPE=Ethernet
DEVICE=em4
BOOTPROTO=none
ONBOOT=yes
NM_CONTROLLED=no
IPV6INIT=no
MASTER=bond0
SLAVE=yes
EOF

BOND1

modprobe bonding
cat << EOF > /etc/sysconfig/network-scripts/ifcfg-bond1
TYPE=Bond
DEVICE=bond1
NAME=bond1
BONDING_MASTER=yes
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.1.91
PREFIX=24
GATEWAY=192.168.1.1
DNS1=192.168.1.1
NM_CONTROLLED=no
BONDING_OPTS="mode=4 miimon=100 lacp_rate=1"
EOF

cat << EOF > /etc/sysconfig/network-scripts/ifcfg-p3p1
TYPE=Ethernet
DEVICE=p3p1
BOOTPROTO=none
ONBOOT=yes
NM_CONTROLLED=no
IPV6INIT=no
MASTER=bond1
SLAVE=yes
EOF

cat << EOF > /etc/sysconfig/network-scripts/ifcfg-p3p2
TYPE=Ethernet
DEVICE=p3p2
BOOTPROTO=none
ONBOOT=yes
NM_CONTROLLED=no
IPV6INIT=no
MASTER=bond1
SLAVE=yes
EOF

测试

cat /proc/net/bonding/bond0
cat /proc/net/bonding/bond1

ping bond0或bond1 IP 线路都是通的。
bond0 或 bond1 断一根网线,不会影响网络。
bond0 断两根网线,bond0无网络。

若bond1光纤网卡所有线路故障,切换bond0为主网络操作

ifconfig bond1 down
route add default gw 192.168.10.1 dev bond0

Bond + Bridge

yum install -y bridge-utils
cat << EOF > /etc/sysconfig/network-scripts/ifcfg-bond0
Type=Bond
DEVICE=bond0
NAME=bond0
BONDING_MASTER=yes
BOOTPROTO=none
ONBOOT=yes
NM_CONTROLLED=no
BRIDGE=br0
BONDING_OPTS="mode=4 miimon=100 lacp_rate=1"
EOF
cat << EOF > /etc/sysconfig/network-scripts/ifcfg-br0
Type=Bridge
DEVICE=br0
NAME=br0
BOOTPROTO=static
NM_CONTROLLED=no
USERCTL=no
ONBOOT=yes
IPADDR=192.168.1.43
PREFIX=24
GATEWAY=192.168.1.1
DNS1=192.168.1.1
cat << EOF > /etc/sysconfig/network-scripts/ifcfg-em1...em4
如bond0 em1...em4配置相同

相关文章

UFW+IPSET 禁用非法IP
ip_local_port_range: prefer different parity for start/end values
Linux Sudo 权限配置
阿里云ECS云盘IOPS压测
nextcloud preview-generate 报错文件无权限解决
tcpdump 抓包使用小结

发布评论