网卡bond

参考如下链接:https://blog.csdn.net/ogog123/article/details/77991067

所谓bond,就是把多个物理网卡绑定成一个逻辑上的网卡,使用同一个IP工作,在增加带宽的同时也可以提高冗余性,一般使用较多的就是来提高冗余,分别和不同交换机相连,提高可靠性,但有时服务器带宽不够了也可以用作增加带宽。

1.网卡bond的模式

网卡绑定mode共有七种(0~6) bond0、bond1、bond2、bond3、bond4、bond5、bond6。 常用的有三种:

mode=0:平衡负载模式,有自动备援,但需要”Switch”支援及设定。

mode=1:自动备援模式,其中一条线若断线,其他线路将会自动备援。

mode=6:平衡负载模式,有自动备援,不必”Switch”支援及设定。

bond模式:

  1. Mode=0(balance-rr) 表示负载分担round-robin,和交换机的聚合强制不协商的方式配合。
  2. Mode=1(active-backup) 表示主备模式,只有一块网卡是active,另外一块是备的standby,这时如果交换机配的是捆绑,将不能正常工作,因为交换机往两块网卡发包,有一半包是丢弃的。
  3. Mode=2(balance-xor) 表示XOR Hash负载分担,和交换机的聚合强制不协商方式配合。(需要xmit_hash_policy)
  4. Mode=3(broadcast) 表示所有包从所有interface发出,这个不均衡,只有冗余机制...和交换机的聚合强制不协商方式配合。
  5. Mode=4(802.3ad) 表示支持802.3ad协议,和交换机的聚合LACP方式配合(需要xmit_hash_policy)
  6. Mode=5(balance-tlb) 是根据每个slave的负载情况选择slave进行发送,接收时使用当前轮到的slave
  7. Mode=6(balance-alb) 在5的tlb基础上增加了rlb。

5和6不需要交换机端的设置,网卡能自动聚合。4需要支持802.3ad。0,2和3理论上需要静态聚合方式
但实测中0可以通过mac地址欺骗的方式在交换机不设置的情况下不太均衡地进行接收。

如何配置:

[root@rhel6 network-scripts]# ls ifcfg-*
ifcfg-eth0  ifcfg-lo
[root@rhel6 network-scripts]# cp ifcfg-eth0 ifcfg-bond0
[root@rhel6 network-scripts]# cp ifcfg-eth0 ifcfg-eth1
[root@rhel6 network-scripts]# cp ifcfg-eth0 ifcfg-eth2
[root@rhel6 network-scripts]# vim ifcfg-bond0 
[root@rhel6 network-scripts]# cat ifcfg-bond0 
DEVICE=bond0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System bond0"
IPADDR=192.168.122.40
NETMASK=255.255.255.0
BONDING_OPTS="mode=0" #负载均衡模式,当BONDING_OPTS="mode=1 primary=eth1"主从模式,eth1为主
[root@rhel6 network-scripts]# vim ifcfg-eth1
[root@rhel6 network-scripts]# vim ifcfg-eth2
[root@rhel6 network-scripts]# cat ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth1"


MASTER=bond0
SLAVE=yes
[root@rhel6 network-scripts]# cat ifcfg-eth2
DEVICE=eth2
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth2"
MASTER=bond0
SLAVE=yes


[root@rhel6 network-scripts]# service network-functions restart
[root@rhel6 network-scripts]# yum -y install iptraf
[root@rhel6 network-scripts]# iptraf


[root@foundation15 ~]# ping 192.168.122.40

原文地址:https://www.cnblogs.com/move-on-change/p/9812861.html