CentOS 多网卡绑定bonding

时间:2023-03-09 20:37:51
CentOS 多网卡绑定bonding

1、查看环境

ip a |grep -v lo

2、加载bonding模块

modprobe bonding

3、开机自动加载模块到内核

echo 'modprobe bonding &> /dev/null' >> /etc/rc.local

4、创建虚拟网卡配置

vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
ONBOOT=yes
BOOTPROTO=static
IPADDR=10.10.3.231
BROADCAST=10.10.3.255
NETMASK=255.255.255.0
GATEWAY=10.10.3.1
TYPE=Ethernet

5、修改真实网卡配置

vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
TYPE=Ethernet
vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
TYPE=Ethernet

6、编辑模块载入配置文件,让系统支持bonding

vi /etc/modprobe.d/bonding.conf
alias bond0 bonding
options bond0 miimon= mode=

7、编辑/etc/rc.local文件,加入如下内容,在系统启动时将虚拟网卡和两张物理网卡相绑定

vi /etc/rc.local
ifenslave bond0 eth0 eth1

8、重启network

service network restart
ip a |grep -v lo