1. Create a file bond0
# vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
NM_CONTROLLED = no # whether the networkmanager to manage your network card, followed by a detailed talk
BOOTPROTO = static # way to get ip address, an optional dynamic (dhcp), static (static), do not get (none)
ONBOOT=yes
IPADDR=192.168.10.33
NETMASK=255.255.255.0
GATEWAY=192.168.10.254
USERCTL = no # whether to allow a user to control the device non-root
BONDING_OPTS = "mode = 1 miimon = 100" # binding mode, detailed later speaking
2, modify the file eth0
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
NM_CONTROLLED=no
ONBOOT=yes
TYPE=Ethernet
MASTER=bond0
SLAVE=yes
USERCTL=no
2, modify eth1 file
# vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
NM_CONTROLLED=no
ONBOOT=yes
TYPE=Ethernet
MASTER=bond0
SLAVE=yes
USERCTL=no
3, add kernel modules
# We /etc/modprobe.d/dist.conf
End of file add the following two lines:
alias bond0 bonding
Options bond0 mode = 1 = 100 miimon
4, set up automatic binding when the system starts
# Vi /etc/rc.d/rc.local
Files added at the end:
ifenslave bond0 eth0 eth1
5, close NetworkManager (if any)
# service NetworkManager stop
# chconfig NetworkManager off
6, reboot the system to see if properly enabled bond0
7, on NM_CONTROLLED
若设置NM_CONTROLLED=yes,则使用networkmanager来管理网卡,重启网络时需要先重启networkmanage,再重启network。对于远程用户来说就可能导致服务器无法再连接。因为重启networkmanager时网络就断了,所以这里一般设置为no
8、关于绑定模式BONDING_OPTS="mode=1 miimon=100"
miimon:一般将miimon值设为100,表示系统每100ms监测一次链路连接状态
mod=0 平衡轮循模式
mod=1 主备模式
mod=2 平衡策略
mod=3 广播策略
mod=4 动态链接聚合
mod=5 适配器传输负载均衡
mod=6 适配器适应性负载均衡
详细解释可以看这里:https://my.oschina.net/jastme/blog/491095