网络bonding

在网卡绑定的七种模式下,其中mode=0、2、3、4需要交换机支持,mode=1、5、6不需要交换机配置支持。

 

创建Mode 0 bonding,并为Bond设置静态IP:

#systemctl start network.service

#nmcli connection add type bond ifname bond0 mode balance-rr

#nmcli connection add type bond-slave ifname eth0 master bond0

#nmcli connection add type bond-slave ifname eth1 master bond0

#nmcli connection up bond-slave-eth0

#nmcli connection up bond-slave-eth1

#nmcli connection modify bond0 ipv4.method manual ipv4.address $IP_ADDR/24 ipv4.gateway $Gateway

#nmcli connection up bond0

#systemctl restart network.service

 

创建Mode 1 bonding,并为Bond设置设置静态IP:

#systemctl start network.service

#nmcli connection add type bond ifname bond0 mode active-backup

#nmcli connection add type bond-slave ifname eth0 master bond0

#nmcli connection add type bond-slave ifname eth1 master bond0

#nmcli connection up bond-slave-eth0

#nmcli connection up bond-slave-eth1

#nmcli connection modify bond0 ipv4.method manual ipv4.address $IP_ADDR/24 ipv4.gateway $Gateway

#nmcli connection up bond0

#systemctl restart network.service

 

创建Mode 4 bonding,并为Bond设置设置静态IP:

#systemctl start network.service

#nmcli connection add type bond ifname bond0 mode 802.3ad

vim /etc/sysconfig/network-scripts/ifcfg-bond-bond0

修改BONDING_OPTS=mode=802.3ad为BONDING_OPTS="mode=4 miimon=100 xmit_hash_policy=layer3+4"

#nmcli connection add type bond-slave ifname eth0 master bond0

#nmcli connection add type bond-slave ifname eth1 master bond0

#nmcli connection up bond-slave-eth0

#nmcli connection up bond-slave-eth1

#nmcli connection modify bond0 ipv4.method manual ipv4.address $IP_ADDR/24 ipv4.gateway $Gateway

#nmcli connection up bond0

#systemctl restart network.service

 

创建Mode 6 bonding,并为Bond设置设置静态IP:

#systemctl start network.service

#nmcli connection add type bond ifname bond0 mode balance-alb

#nmcli connection add type bond-slave ifname eth0 master bond0

#nmcli connection add type bond-slave ifname eth1 master bond0

#nmcli connection up bond-slave-eth0

#nmcli connection up bond-slave-eth1

#nmcli connection modify bond0 ipv4.method manual ipv4.address $IP_ADDR/24 ipv4.gateway $Gateway

#nmcli connection up bond0

#systemctl restart network.service

 

#cat /proc/net/bonding/bond0    检查Bonding Mode

 

 

删除bond:Ubuntu需要nmcli工具 #apt install network-manager

#nmcli connection delete bond-slave-eth0

#nmcli connection delete bond-slave-eth1

#nmcli connection delete bond0

 

posted @ 2024-05-28 14:34  Sky_Liao  阅读(44)  评论(0)    收藏  举报