双网卡绑定之mode=6

因项目需求不使用mode=0模式在交换机上做聚合操作,所以研究了mode=6

mode=6的好处就是eth0,eth1的mac地址是不同的,所以可以在同一台交换机上使用;

下面写一下具体的做法:

1.bond0的配置信息

DEVICE=bond0
BONDING_OPTS='miimon=100 mode=6'
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.1.61
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
USERCTL=no

eth0的配置信息

DEVICE=eth0
HWADDR=D0:50:99:C1:0E:83
TYPE=Ethernet
UUID=5eefe89c-0cbf-426c-987e-1b6ee1c54024
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
USERCTL=no

eth1的配置信息

DEVICE=eth1
HWADDR=D0:50:99:C1:0E:81
TYPE=Ethernet
UUID=a71f51f5-c05b-4bcd-a618-bb09813be60e
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
USERCTL=no

注意:eth0和eth1的mac地址不能一样(不要cpeth0或别的),否则交换机不能识别

2.修改配置文件

vi /etc/modprobe.d/bonding.conf

alias bond0 bonding

3.加载bond模块

modprobe bonding

重启网卡

service network restart

4.查看bond0是否生效

cat /proc/net/bonding/bond0

Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)


Bonding Mode: adaptive load balancing
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: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: d0:50:99:c1:0e:83
Slave queue ID: 0


Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: d0:50:99:c1:0e:81
Slave queue ID: 0


注意:Bonding Mode: adaptive load balancing很重要,代表mode=6成功了

另:mode=6他的工作机制是先占满eth0的网络,再占eth1的,,,以此类推,所以除非压力很大否则不会使用另一个 网口


测试成果




拔掉一根网线

修改bond模式

cat /etc/modprobe.d/dist.conf

结尾处修改,
options bond0 miimon=100 mode=1
配置文件修改,ifcfg-bond0结尾添加
BONDING_OPTS="mode=1 miimon=100"

service network stop
rmmod bonding
modprobe bonding
service network restart

确定是否已修改(mode=1):
mode=4,会看到802.字样
[root@public-elk-2 ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

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

Slave Interface: em1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 18:66:da:b4:1b:3b
Slave queue ID: 0

Slave Interface: em2
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 18:66:da:b4:1b:3c
Slave queue ID: 0



你可能感兴趣的:(linux)