现状:

    目前一台物理机4个网卡,em1-em2-em3-em4,需要实现1、2网卡绑定,3、4网卡绑定,模式为主备。即:一个网卡处于活动状态 ,一个处于备份状态,所有流量都在主链路上处理。当活动网卡down掉时,启用备份的网卡

    附:linux有七种网卡绑定模式:0. round robin,1.active-backup,2.load balancing (xor),  3.fault-tolerance (broadcast), 4.lacp,  5.transmit load balancing, 6.adaptive load balancing。

自动化脚本如下:

function init_em() {
cat>/etc/sysconfig/network-scripts/ifcfg-em1</etc/sysconfig/network-scripts/ifcfg-em2</etc/sysconfig/network-scripts/ifcfg-em3</etc/sysconfig/network-scripts/ifcfg-em4</etc/sysconfig/network-scripts/ifcfg-bond0</etc/sysconfig/network-scripts/ifcfg-bond1<>/etc/modprobe.d/dist.conf</etc/resolv.conf<