ubuntu多网口bonding

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.csdn.net/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.csdn.net/sven_007/article/details/7744416

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



猜你喜欢

转载自blog.csdn.net/weixin_41947658/article/details/88177952