Ubuntu 多网口绑定bond

本文详细介绍了Linux bonding驱动技术,包括其工作原理、模式选择、配置方法及安装步骤,旨在实现网络负载均衡与冗余。通过轮询策略、活动备份策略等模式,确保网络稳定性和数据传输效率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://www.cnblogs.com/khldragon/p/3642367.html

http://my.oschina.net/zphj1987/blog/77890

http://www.linuxidc.com/Linux/2011-01/31048.htm

官方文档:https://www.kernel.org/doc/Documentation/networking/bonding.txt

http://blog.youkuaiyun.com/fyang2007/article/details/5964357 MII (Media Independent Interface(介质无关接口);或称为媒体独立接口

http://blog.chinaunix.net/uid-49097-id-78251.html Linux bonding 模式中文手册

什么是bonding

  Linux bonding 驱动提供了一个把多个网络接口设备捆绑为单个的网络接口设置来使用,用于网络负载均衡及网络冗余。
  bonding的工作模式

  bonding一共有7种工作模式

  0:(balance-rr) Round-robin policy: (平衡轮询策略):传输数据包顺序是依次传输,直到最后一个传输完毕, 此模式提供负载平衡和容错能力。
  1:(active-backup) Active-backup policy:(活动备份策略):只有一个设备处于活动状态。 一个宕掉另一个马上由备份转换为主设备。mac地址是外部可见得。 此模式提供了容错能力。
  2:(balance-xor) XOR policy:(平衡策略):传输根据[(源MAC地址xor目标MAC地址)mod 设备数量]的布尔值选择传输设备。 此模式提供负载平衡和容错能力。
  3:(broadcast) Broadcast policy:(广播策略):将所有数据包传输给所有设备。 此模式提供了容错能力。
  4:(802.3ad) IEEE 802.3ad Dynamic link aggregation. IEEE 802.3ad 动态链接聚合:创建共享相同的速度和双工设置的聚合组。此模式提供了容错能力。每个设备需要基于驱动的重新获取速度和全双工支持;如果使用交换机,交换机也需启用 802.3ad 模式。
  5:(balance-tlb) Adaptive transmit load balancing(适配器传输负载均衡):通道绑定不需要专用的交换机支持。发出的流量根据当前负载分给每一个设备。由当前设备处理接收,如果接受的设备传不通就用另一个设备接管当前设备正在处理的mac地址。
  6:(balance-alb) Adaptive load balancing: (适配器负载均衡):包括mode5,由 ARP 协商完成接收的负载。bonding驱动程序截获 ARP 在本地系统发送出的请求,用其中之一的硬件地址覆盖从属设备的原地址。就像是在服务器上不同的人使用不同的硬件地址一样。

1、安装软件

  ifenslave一种粘合和分离式的软件,可以将数据包有效的分配到bonding驱动。

apt-get install ifenslave

2、修改配置文件,根据自己需要修改即可。

vi /etc/network/interfaces
 
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
 
# The loopback network interface
auto lo
iface lo inet loopback
 
#注释掉原来的eth0,eth1配置
# The primary network interface
#auto eth0
#iface eth0 inet dhcp
 
#auto eth1
#iface eth1 inet dhcp
 
#这里配置模式为轮询策略,模式代号是0,轮询间隔100ms(毫秒)。
up ifenslave bond0 eth0 eth1
down ifenslave bond0 -d eth0 eth1
bond-mode 0
bond-miimon 100
 
#配置bond的IP
auto bond0
iface bond0 inet static
address 192.168.0.201
netmask 255.255.255.0
gateway 192.168.0.1
 
#配置bond的虚拟IP(非必须)
auto bond0:1
iface bond0:1 inet static
address 192.168.1.201
netmask 255.255.255.0
gateway 192.168.1.1
3、加载bonding模块
sudo gedit /etc/modules
bonding
4、重启计算机,如果成功,bond0、eth0、eth1的MAC地址均会变成原来eth0的MAC。
sudo shutdown -r now

5、查看bonding状态

 cat /proc/net/bonding/bond0

也可以用ifconfig 查看!

执行

 写道
/etc/init.d/networking restart

完成以后,同样可以查看一下bonding的状态

 写道

root@132:/etc/network# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 0
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:10:5c:ef:b2:a2
Slave queue ID: 0

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:10:5c:ef:b2:a3
Slave queue ID: 0


参考文献:

1、http://blog.youkuaiyun.com/sven_007/article/details/7744416

2、http://www.mike.org.cn/articles/ubuntu-nic-balancing/



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值