Linux Bond 以及Mode 1实验

概述

今天主要想聊一聊VXLAN环境中终端设备(Linux系统)的接入方式,在VXLAN组网中,终端一般会双上联到两台Leaf以增强组网的健壮性,
这时一般就会有两个方案:

  1. 两台Leaf通过堆叠、M-Lag、ESI-Lag等技术,使两台Leaf交换机能在逻辑上视为一台,这样的话两台Leaf就可以跨设备聚合和Linux终端做802.3ad对接,也就是Linux的Bond Mode 4;
  2. 两台Leaf仍然保持独立,Linux终端配置Bond Mode1主备模式或是5、6负载均衡模式,对接到两台不同交换机。

我们先看Mode 1,下面是从官方网站对Mode 1的解释和fail_over_mac 这个参数的意思,会在配置时用到。
官网链接

active-backup or 1
Active-backup policy: Only one slave in the bond is
active. A different slave becomes active if, and only
if, the active slave fails. The bond’s MAC address is
externally visible on only one port (network adapter)
to avoid confusing the switch.

In bonding version 2.6.2 or later, when a failover
occurs in active-backup mode, bonding will issue one
or more gratuitous ARPs on the newly active slave.
One gratuitous ARP is issued for the bonding master
interface and each VLAN interfaces configured above
it, provided that the interface has at least one IP
address configured. Gratuitous ARPs issued for VLAN
interfaces are tagged with the appropriate VLAN id.

This mode provides fault tolerance. The primary
option, documented below, affects the behavior of this
mode.

fail_over_mac = 1
The “active” fail_over_mac policy indicates that the
MAC address of the bond should always be the MAC
address of the currently active slave. The MAC
address of the slaves is not changed; instead, the MAC
address of the bond changes during a failover.

Mode 1之所以不需要对端交换机配合,是因为Bond的成员口其实只有一个处于活跃状态,并且对外发布这个活跃接口的MAC地址,如果当前的活跃接口故障,那么另一个接口接替工作,同时Bond的MAC地址也发生了变化。
因此对交换机根本感知不到终端是配置了Bond,Bond的切换过程就像是重新断开又接入了新的终端;而远端设备的ARP缓存记录也会被刷新。
另外还有一点我们需要明白,一张VXLAN Fabric完全可以当作一台大交换机,所以终端能通过Mode1,5,6可以接到两台没配置类堆叠的Leaf交换机。理解这个我们就可以搭建一个简单的实验拓扑。

拓扑图

我的模拟拓扑图,两台Centos7虚机,和一台交换机(既可以是一台物理交换机,也可以是一个VXLAN Fabric)。
H1两个接口en0s8和enp0s9连到SW,依次配置Mode1,5,6,SW无需做bond相关的配置;
H2上起了两个namespace,ns1和ns2,接口en0s9放到了ns1和enp0s8放到了ns2;
H1的IP:10.0.0.11,H2-ns1的IP:10.0.0.112,H2-ns2的IP:10.0.0.12;
如果对Namespace操作不熟悉,可以参考这边文章。Namespace文章
在这里插入图片描述

Mode1配置

配置不是很复杂,可以参照redhat官网。官方链接
加载Bond并查看
modprobe --first-time bonding
modinfo bonding
新建一个Bond文件命名为Bond0,配置文件
cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
TYPE=Bond
BONDING_MASTER=yes
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=“bond0”
IPADDR=10.0.0.11
PREFIX=24
ONBOOT=yes
BONDING_OPTS=“miimon=100 mode=1 fail_over_mac=1”
NM_CONTROLLED=“no”
两个物理口配置文件类似
cat /etc/sysconfig/network-scripts/ifcfg-enp0s8
NAME=bond0-slave
UUID=b6416eae-4958-46ff-bb03-399d752f3c2b
DEVICE=enp0s8
TYPE=Ethernet
BOOTPROTO=none
IPV4_FAILURE_FATAL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
NM_CONTROLLED=“no”
配置完重启网络
systemctl restart network

实验记录

Mode状态

当前active接口是enp0s8,bond0的MAC 地址是enp0s8的MAC a001
在这里插入图片描述
查看当前接口的MAC,bond0的MAC就是enp0s8的MAC a001
在这里插入图片描述
在这里插入图片描述
H2-ns1和H2-ns2的ARP记录,只有a001这个MAC
在这里插入图片描述
在这里插入图片描述
H2-ns1和H2-ns2同时ping H1,通过nload观察流量负载情况,
只有enp0s8承载流量。
在这里插入图片描述
把enp0s8 down掉,enp0s9变成active,

在这里插入图片描述
bond0继承enp0s9的MAC a002
在这里插入图片描述
在这里插入图片描述

此时,H2-ns1和H2-ns2上的arp记录,MAC地址变成了a002
在这里插入图片描述
在这里插入图片描述

nload观察流量已经切到了enp0s9
在这里插入图片描述
Mode 1 实验完毕,实验结果和官网上的解释一致。
Mode1 只有一个活跃的接口,和对外发布一个MAC地址,当前活跃接口故障后,会切到另一接口,MAC也发生变化并通过免费ARP通告。
后续在补充Mode 5,6 …

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值