网络接口配置——bonding

将多块网卡绑定同一IP地址,对外提供服务,即通过bonding虚拟一块网卡。多个网卡绑定的工作模式一共有7中,主要有:

1.Mode 0:轮转策略

2.Mode 1:备份策略

3.Mode 3:广播策略

可以通过一系列的配置,将主机上的几个网卡绑定,实现bonding的各种工作模式,具体步骤:

一、centos 6网卡绑定:

1.创建bonding设备的配置文件:/etc/sysconfig/network-scripts/ifcfg-bond0 (其中ifcfg-bong0为虚拟网卡的名称)


网络接口配置——bonding


DEVICE=bond0

BOOTPROTO=none

BONDING_OPTS="miimon=100  mode=0" (网卡互相通信的时间为100毫秒,工作模式为0)


网络接口配置——bonding


2.各网卡的配置文件中填写:

MASTER=bond0

SLAVE=yes

USERCTL=no


网络接口配置——bonding


3.重启网络服务:

service network restart


网络接口配置——bonding


此时,各个网卡没有ip地址,但MAC地址相同

4.解除绑定:

关闭bond0网卡:ifconfig bond0 down

删除文件:rm  -rf  ifconfig-bond0


网络接口配置——bonding


更改网卡的配置文件

二、centos 7网卡绑定:

1.添加bonding接口:

nmcli con add type bond con-name bond0 ifname bond0 mode active-backup


网络接口配置——bonding


2.添加从属接口(物理网卡):

nmcli con add type bond-slave   ifname eth0  master bond0


网络接口配置——bonding


3.启动从属接口:

nmcli  con up bond0-slave-eth1


网络接口配置——bonding


4.启动绑定:

nmcli con up bond0

5.解除绑定:

nmcli  connection  down  bond0


网络接口配置——bonding



nmcli  con delete  bond0


网络接口配置——bonding


nmcli con delete  bond-slave-eth0


网络接口配置——bonding

总结:多块网卡绑定同一ip地址,若其中一块网卡损坏,并不会影响服务,还可以加倍网络带宽,提高工作效率。