Linux Bonding模式 Mode 1 主备模式 MAC切换研究成果分享

前提说明:

以下是在操作系统版本:ubuntu 18.4.3 Bonding Driver: v3.7.1 下测试
bond x :特指创建的Bond虚拟网卡(逻辑网卡、虚拟网卡)

ens38 、 ens39 :特指第一次系统装机系统识别的物理网卡名称

验证时间:2020年2月28日 21:10 至 02:20

特别声明:
我验证的bonding模式 : Mode 1 主备模式

————————————————————————————————

1.第一次创建bonding:出厂烧录固件源mac会被写入bonding 参数:Permanent HW addr(永久写入此函数,对于变量(内存值)为静态变量)

2.fail-over-mac-policy参数:MAC地址故障恢复策略,Slave网络链路发生断开,bond x接口的mac会发生改变,而bond x的mac 发生改变,即时作用于Slave成员网卡。作用方式取决于fail-over-mac-policy参数值。
3.在Bonding Driver: v3.7.1下创建bonding虚拟接口bond x 的时候,从配置参数里读出的主Slave的mac会成为bond x 虚拟接口的主mac,至于其它Slave网卡(两个,三个,甚至更多个Slave mac怎么变由fail-over-mac-policy指定,fail-over-mac-policy 默认值为:none)

4.下面是fail-over-mac-policy三个值none 、active、 follow 含义:

4.1 fail-over-mac-policy: none

配置文件指定 primary: ens38,此时ens38成为Currently Active Slave,bond x虚拟接口mac地址为ens38的,当Bonding MII监测active ens38链路发生改变, 此时ens39成为活动网卡,bond虚拟网卡的mac继续保持第一次活动网卡ens38的,ens39的也继续保持不变,只是Bonding活动网卡变为ens39 ,bond x 的MAC地址从第一次读取Active 网卡MAC的后无论Slave链路怎么变,MAC永久保持不变

Slave 网卡永远随bond x改变而改变,如果此时手工把bond x MAC地址变为ab.cd.ef.gh 那么所有Slave同时会变成ab.cd.ef.gh, 用ip a命令即可查看 , MAC:一改改全部

4.2 fail-over-mac-policy: active

配置文件指定 primary: ens38,此时ens38成为Currently Active Slave,bond x虚拟接口mac地址为ens38的, 当Bonding MII监测active ens38链路发生改变, 此时ens39成为活动网卡,bond虚拟网卡的mac变到ens39的, 此时Bonding活动网卡变为ens39,bond x 接口地址永远追随当前active网卡的mac变化而变化,MAC:只改bond x 的

4.3 fail-over-mac-policy: follow

配置文件指定 primary: ens38,此时ens38成为Currently Active Slave,bond x虚拟接口mac地址为ens38的, 当Bonding MII监测active ens38链路发生改变, 此时ens39成为活动网卡,bond虚拟网卡的mac继续保持第一次活动网卡ens38的,同时将ens39的变为和bond的口一致的mac(ens38),此时掉头把ens38的mac改写为ens39的,此时Bonding活动网卡变为ens39 MAC: bond x的mac 永久保持不变,原active Slave(现在down了)与stand-by Slave(现在up了成为active了)交换mac

5.当你用ip addr show 看到的地址就是bonding驱动作用下的结果,无论此时的bond x接口是服务器网卡原厂烧录的mac 还是后期脚本或是手工更改的,这就是真真实实被使用的,都会被fail-over-mac-policy参数值管控,都会被存到系统内存函数里,此刻的mac就在fail-over-mac-policy的作用下被管控和被系统使用着的
6.bond接口驱动架构 Slave网卡(物理网卡) 网卡驱动 上行bonding驱动(接管Slave设备,通过控制Slave驱动更改Slave网卡MAC等) 上行bonding 虚拟接口 bonding驱动 上行网络设备


为大家在提供额外的参数,供大家使用:可以灵活搭配灵活使用
parameters:

          mode (scalar)
                 Set the bonding mode used for the interfaces.  The default is balance-rr (round robin).  Possible values are balance-rr, active-back‐
                 up, balance-xor, broadcast, 802.3ad, balance-tlb, and balance-alb.

          lacp-rate (scalar)
                 Set the rate at which LACPDUs are transmitted.  This is only useful in 802.3ad mode.  Possible values are slow (30 seconds, default),
                 and fast (every second).

          mii-monitor-interval (scalar)
                 Specifies  the interval for MII monitoring (verifying if an interface of the bond has carrier).  The default is 0; which disables MII
                 monitoring.  This is equivalent to the MIIMonitorSec= field for the networkd backend.  If no time suffix is specified, the value will
                 be interpreted as milliseconds.

          min-links (scalar)
                 The minimum number of links up in a bond to consider the bond interface to be up.

          transmit-hash-policy (scalar)
                 Specifies  the  transmit hash policy for the selection of slaves.  This is only useful in balance-xor, 802.3ad and balance-tlb modes.
                 Possible values are layer2, layer3+4, layer2+3, encap2+3, and encap3+4.

          ad-select (scalar)
                 Set the aggregation selection mode.  Possible values are stable, bandwidth, and count.  This option is only used in 802.3ad mode.

          all-slaves-active (bool)
                 If the bond should drop duplicate frames received on inactive ports, set this option to false.  If they should be delivered, set this
                 option to true.  The default value is false, and is the desirable behavior in most situations.

          arp-interval (scalar)
                 Set  the interval value for how frequently ARP link monitoring should happen.  The default value is 0, which disables ARP monitoring.
                 For the networkd backend, this maps to the ARPIntervalSec= property.  If no time suffix is specified, the value will  be  interpreted
                 as milliseconds.

          arp-ip-targets (sequence of scalars)
                 IPs  of  other hosts on the link which should be sent ARP requests in order to validate that a slave is up.  This option is only used
                 when arp-interval is set to a value other than 0.  At least one IP address must be given for ARP link monitoring to  function.   Only
                 IPv4 addresses are supported.  You can specify up to 16 IP addresses.  The default value is an empty list.

          arp-validate (scalar)
                 Configure how ARP replies are to be validated when using ARP link monitoring.  Possible values are none, active, backup, and all.

          arp-all-targets (scalar)
                 Specify  whether  to  use any ARP IP target being up as sufficient for a slave to be considered up; or if all the targets must be up.
                 This is only used for active-backup mode when arp-validate is enabled.  Possible values are any and all.
          up-delay (scalar)
                 Specify the delay before enabling a link once the link is physically up.  The default value is 0.  This maps to the UpDelaySec= prop‐
                 erty for the networkd renderer.  If no time suffix is specified, the value will be interpreted as milliseconds.

          down-delay (scalar)
                 Specify the delay before disabling a link once the link has been lost.  The default value is 0.  This maps to the DownDelaySec= prop‐
                 erty for the networkd renderer.  If no time suffix is specified, the value will be interpreted as milliseconds.

          fail-over-mac-policy (scalar)
                 Set whether to set all slaves to the same MAC address when adding them to the bond, or how else the system should handle MAC address‐
                 es.  The possible values are none, active, and follow.

          gratuitous-arp (scalar)
                 Specify  how many ARP packets to send after failover.  Once a link is up on a new slave, a notification is sent and possibly repeated
                 if this value is set to a number greater than 1.  The default value is 1 and valid values are between 1 and 255.  This  only  affects
                 active-backup mode.

                 For historical reasons, the misspelling gratuitious-arp is also accepted and has the same function.

          packets-per-slave (scalar)
                 In  balance-rr  mode, specifies the number of packets to transmit on a slave before switching to the next.  When this value is set to
                 0, slaves are chosen at random.  Allowable values are between 0 and 65535.  The default value is 1.  This setting  is  only  used  in
                 balance-rr mode.

          primary-reselect-policy (scalar)
                 Set  the reselection policy for the primary slave.  On failure of the active slave, the system will use this policy to decide how the
                 new active slave will be chosen and how recovery will be handled.  The possible values are always, better, and failure.

          resend-igmp (scalar)
                 In modes balance-rr, active-backup, balance-tlb and balance-alb, a failover can switch IGMP traffic from one slave to another.

                 This parameter specifies how many IGMP membership reports are issued on a failover event.  Values range from 0 to  255.   0  disables
                 sending  membership reports.  Otherwise, the first membership report is sent on failover and subsequent reports are sent at 200ms in‐
                 tervals.

          learn-packet-interval (scalar)
                 Specify the interval between sending learning packets to each slave.  The value range is between 1 and 0x7fffffff.  The default value
                 is  1.  This option only affects balance-tlb and balance-alb modes.  Using the networkd renderer, this field maps to the LearnPacket‐
                 IntervalSec= property.  If no time suffix is specified, the value will be interpreted as seconds.

          primary (scalar)
                 Specify a device to be used as a primary slave, or preferred device to use as a slave for the bond (ie.  the preferred device to send
                 data through), whenever it is available.  This only affects active-backup, balance-alb, and balance-tlb modes.

你可能感兴趣的:(linux,虚拟层网络技术)