Octet

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

ModeNameSwitch sideHow it sends
0balance-rrStatic channelPacket by packet round robin, reorders TCP
1active-backupNothingOne active link, others standby
2balance-xorStatic channelHash per flow (xmit_hash_policy)
3broadcastStatic channelEvery packet on every link
4802.3adLACPHash per flow, LACP negotiates members
5balance-tlbNothingOutbound spread by load, inbound on one link
6balance-albNothingtlb 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 ens1f0 in 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.

Traps

  • Using mode 0 or 2 against switch ports with no channel configured. The switch sees the MAC flap between ports.
  • Leaving miimon unset and discovering the bond never failed over.
How did you do?