What are the Linux bonding modes, and which ones need configuration on the switch?
Show the answer
Say this first
Seven modes, 0 to 6. Mode 1, active-backup, needs nothing on the switch and works across two switches. Mode
4, 802.3ad, is LACP and needs an LACP port-channel on the switch (or MLAG across two). Modes 0
(balance-rr), 2 (balance-xor) and 3 (broadcast) need a static EtherChannel. Modes 5 (balance-tlb) and 6
(balance-alb) balance without switch support by playing with MACs. In a data centre I use mode 4 with
miimon 100, and mode 1 when the switches cannot bundle.
Go deeper
The table
| Mode | Name | Switch side | How it sends |
|---|---|---|---|
| 0 | balance-rr | Static channel | Packet by packet round robin, reorders TCP |
| 1 | active-backup | Nothing | One active link, others standby |
| 2 | balance-xor | Static channel | Hash per flow (xmit_hash_policy) |
| 3 | broadcast | Static channel | Every packet on every link |
| 4 | 802.3ad | LACP | Hash per flow, LACP negotiates members |
| 5 | balance-tlb | Nothing | Outbound spread by load, inbound on one link |
| 6 | balance-alb | Nothing | tlb plus inbound IPv4 spread by answering ARP with different slave MACs |
Parameters that matter
miimon 100: check link state every 100 ms. Without a monitor the bond never notices a failure.lacp_rate fast: ask the partner to send LACPDUs every second instead of every 30.xmit_hash_policy:layer2(default),layer2+3,layer3+4.primary ens1f0in active-backup to prefer one link.
Checking it
cat /proc/net/bonding/bond0 shows the mode, the active slave or the LACP aggregator, and each slave's
link state and failure count.
They will ask next
Two top-of-rack switches without MLAG. Which mode?
Active-backup (mode 1). LACP needs both links to end on one logical switch; with two independent switches the second link ends up in a different aggregator and carries nothing. With vPC or MLAG, mode 4 works.
Why does active-backup send gratuitous ARP on failover?
The bond's MAC now appears on a different switch port. The gratuitous ARP (and the frame it causes) makes the switches update their MAC tables at once instead of waiting for the old entry to age out.
Traps
- Using mode 0 or 2 against switch ports with no channel configured. The switch sees the MAC flap between ports.
- Leaving
miimonunset and discovering the bond never failed over.