網卡綁定bond

本人測試環境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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章