注意:配置bond要有两个以上的网口
1、配置文件所有目录:/etc/sysconfig/network-scripts
网口配置文件名规则:以ifcfg-开头,然后接着是网口名
例如:eth0的配置文件名是 ifcfg-eth0
如果没有配置文件,则需要创建网口配置文件(需要eth0和eth1)
cd /etc/sysconfig/network-scripts/
2、创建eth0的配置文件
# cat ifcfg-eth0
DEVICE=eth0 #网口名
ONBOOT=yes #LINUX在启动时激活该网口
BOOTPROTO=none #使用什么协议激活网口,none不使用任何协议,如果是静态IP,需要设置为static;如果是动态获取IP,需要设置为dhcp 动态主机配置协议(Dynamic host configuration protocol)
MASTER=bond0 #指定虚拟网口的名字
SLAVE=yes #备用
3、创建eth1的配置文件
#cp ifcfg-eth0 ifcfg-eth1
# cat ifcfg-eth1
DEVICE=eth1 #网口名
ONBOOT=yes #LINUX在启动时激活该网口
BOOTPROTO=none #使用什么协议激活网口,none不使用任何协议,如果是静态IP,需要设置为static;如果是动态获取IP,需要设置为dhcp 动态主机配置协议(Dynamic host configuration protocol)
MASTER=bond0 #指定虚拟网口的名字
SLAVE=yes #备用
4、找到bond0配置文件,没有的话就创建一个
# cat ifcfg-bond0
DEVICE=bond0
ONBOOT=yes
BOOTPROTO=static
IPADDR=172.16.1.3
NETMASK=255.255.0.0
5、配置bonding
在/etc/modprobe.d/dist.conf(没有该文件就创建) 增加以下2行
alias bond0 bonding
options bond0 miimon=100 mode=1
6、重启os
reboot