本人测试环境centos6.4_x86
使用kvm虚拟机创建2个网卡
virsh edit vm1
<interface type='bridge'>
<mac address='52:54:00:74:c9:05'/>
<source bridge='br0'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<interface type='bridge'>
<mac address='52:54:00:74:c9:04'/>
<source bridge='br0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</interface>
加入上面网卡信息
进入系统操作
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# cat ifcfg-eth0 ;cat ifcfg-eth1;cat ifcfg-bond0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
USERCTL=no
MASTER=bond0
SLAVE=yes
DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
USERCTL=no
MASTER=bond0
SLAVE=yes
DEVICE=bond0
BOUND_MASTER=yes
BOUND_SLAVE0=eth0
BOUND_SLAVE1=eth1
IPADDR=10.140.55.35
NETMASK=255.255.255.0
GATEWAY=10.140.55.250
DNS1=10.140.4.17
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=static
USERCTL=no
ifcfg-bond0是我之前就创建好了的,注意3个配置文件红色标记
接着
[root@localhost network-scripts]# cd /etc/modprobe.d/
[root@localhost modprobe.d]# vim bond.conf
alias bond0 bonding
options bond0 miimon=100 mode=0 <--每100秒侦测一次链路状态,模式0(负载均衡)
保存退出
以上操作意思是在系统启动时加载bond模块,手动加载可以这样:
[root@localhost network-scripts]#modprobe bonding
然后再
[root@localhost network-scripts]#service restart network
[root@localhost network-scripts]#ifconfig bond0
bond0 Link encap:Ethernet HWaddr 52:54:00:74:C9:05
inet addr:10.140.55.35 Bcast:10.140.55.255 Mask:255.255.255.0
inet6 addr: fe80::5054:ff:fe74:c905/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:4351 errors:0 dropped:0 overruns:0 frame:0
TX packets:646 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:365536 (356.9 KiB) TX bytes:107199 (104.6 KiB)
[root@localhost network-scripts]#cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)
Bonding Mode: load balancing (round-robin) <--0模式
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth0
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 52:54:00:74:c9:05
Slave queue ID: 0
Slave Interface: eth1
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 52:54:00:74:c9:04
Slave queue ID: 0