使用bonding技术实现双网卡绑定

 使用bonding技术实现双网卡绑定
 
 1、两块网卡绑定一个虚拟网卡
 
 2、Linux的内核默认是否已经支持了,可以通过 modinfo bonding 来查看
  [root@sxs ~]# modinfo bonding
filename:       /lib/modules/2.6.18-92.el5/kernel/drivers/net/bonding/bonding.ko
author:         Thomas Davis, tadavis@lbl.gov and many others
description:    Ethernet Channel Bonding Driver, v3.2.4
version:        3.2.4
license:        GPL
srcversion:     DB2ABCD47A83F8567EBE92B
depends:       
vermagic:       2.6.18-92.el5 SMP mod_unload gcc-4.1
parm:           max_bonds:Max number of bonded devices (int)
parm:           miimon:Link check interval in milliseconds (int)
parm:           updelay:Delay before considering link up, in milliseconds (int)
parm:           downdelay:Delay before considering link down, in milliseconds (int)
parm:           use_carrier:Use netif_carrier_ok (vs MII ioctls) in miimon; 0 for off, 1 for on (default) (int)
parm:           mode:Mode of operation : 0 for balance-rr, 1 for active-backup, 2 for balance-xor, 3 for broadcast, 4 for 802.3ad, 5 for balance-tlb, 6 for balance-alb (charp)
parm:           primary:Primary network device to use (charp)
parm:           lacp_rate:LACPDU tx rate to request from 802.3ad partner (slow/fast) (charp)
parm:           xmit_hash_policy:XOR hashing method: 0 for layer 2 (default), 1 for layer 3+4 (charp)
parm:           arp_interval:arp interval in milliseconds (int)
parm:           arp_ip_target:arp targets in n.n.n.n form. (array of charp)
parm:           arp_validate:validate src/dst of ARP probes: none (default), active, backup or all (charp)
parm:           fail_over_mac:For active-backup, do not set all slaves to the same MAC.  0 of off (default), 1 for on. (int)
module_sig:     883f35048175a9e6e24e25c96667c37112449509f5739ebf283efa5295d315b73cee5e956f6e25709cbcf2826571c5ffc20f2d87672bb921d610d7
[root@sxs ~]#


 3、vi /etc/sysconfig/network-scripts/ifcfg-bond0   加入以下:
       DEVICE=bond0
       NETWORK=172.25.0.0
       IPADDR=172.25.7.202
       NETMASK=255.255.248.0
       BROADCAST=172.25.7.255
       NBOOT=yes
       BOOTPROTO=none
       USERCTL=no
       GATEWAY=172.25.0.254
       TYPE=Ethernet
      
      
 4、vi /etc/sysconfig/network-scripts/ifcfg-eth0
 
DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none


 5、vi /etc/sysconfig/network-scripts/ifcfg-eth1
 
DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

 6、vi /etc/modprobe.conf
加入两行
alias bond0 bonding
options bond0 miimon=100 mode=1
参数miimon是链路监测。miimon=100,表示系统每100ms监测一次链路连接状态,如果有一条线路不通就
转入另一条线路。
参数mode表示工作模式。
mode=0表示load balancing两块网卡同时工作,提供负载均衡。
mode=1表示fault-tolerance提供冗余功能,工作方式是主备的工作方式,提供高可用。

  配置完毕后重启机器,启动过程中show details可以看到bonding启动成功。
 
 
 4.察看bonding运行状态
[root@sxs ~]# ifconfig
bond0     Link encap:Ethernet  HWaddr 00:0C:29:2A:C7:AE 
          inet addr:172.25.7.202  Bcast:172.25.7.255  Mask:255.255.248.0
          inet6 addr: fe80::20c:29ff:fe2a:c7ae/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
          RX packets:34751 errors:0 dropped:0 overruns:0 frame.:0
          TX packets:1319 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2405136 (2.2 MiB)  TX bytes:187511 (183.1 KiB)

eth0      Link encap:Ethernet  HWaddr 00:0C:29:2A:C7:AE 
          inet6 addr: fe80::20c:29ff:fe2a:c7ae/64 Scope:Link
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:16413 errors:0 dropped:0 overruns:0 frame.:0
          TX packets:776 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1132290 (1.0 MiB)  TX bytes:109473 (106.9 KiB)
          Base address:0x2000 Memory:d8920000-d8940000

eth1      Link encap:Ethernet  HWaddr 00:0C:29:2A:C7:AE 
          inet6 addr: fe80::20c:29ff:fe2a:c7ae/64 Scope:Link
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:18338 errors:0 dropped:0 overruns:0 frame.:0
          TX packets:543 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1272846 (1.2 MiB)  TX bytes:78038 (76.2 KiB)
          Base address:0x2040 Memory:d8940000-d8960000

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:3158 errors:0 dropped:0 overruns:0 frame.:0
          TX packets:3158 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:265840 (259.6 KiB)  TX bytes:265840 (259.6 KiB)

  [root@sxs ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.2.4 (January 28, 2008)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:2a:c7:b8

Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:2a:c7:ae
[root@sxs ~]#


随便拔一个网口的网线,不会有掉包的情况


 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7685986/viewspace-716758/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/7685986/viewspace-716758/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值