19.4. Combining Physical Links
One cable is one failure away from silence. The kernel's bonding driver aggregates several physical interfaces into one logical device with one address, and picks a distribution or failover policy - the mode. The address lives on the bond; the member interfaces, called slaves, carry only the link.
19.4.1. Bonding Modes and Switch Requirements
The mode determines everything else: who sends, on which member, and what the switch must be told.
| Mode | Name | Switch requirement | Behavior |
|---|---|---|---|
balance-rr (0) |
round-robin | none, but many switches mishandle it | Frames alternate across members; aggregates bandwidth but reorders frames within a conversation. |
active-backup (1) |
active-backup | none | One member carries all traffic; others stand by. MAC moves with the active member. |
balance-xor (2) |
XOR hash | static aggregation (no negotiation) | Each conversation pins to one member chosen by a hash of addresses. |
broadcast (3) |
broadcast | static aggregation | Every member carries every frame; for links that must never drop a packet, at heavy cost. |
802.3ad (4) |
LACP | dynamic LACP aggregation | Standards-based negotiation; distributes conversations across members, shares the same MAC. |
balance-tlb (5) |
adaptive transmit LB | none | Outbound distributed by per-peer hash; inbound follows the active member. |
balance-alb (6) |
adaptive LB | none | Adds inbound balancing by rewriting ARP replies; interfering with some VM and NIC setups. |
The numbers are historical (Linux kept them while naming the modes);
networkd's Mode= accepts the names. For two hosts sharing redundant
links, active-backup is the honest baseline: it needs no switch
cooperation, failover is one member-swap, and the only observable
effect at the far end is a MAC address moving ports. The aggregation
modes pay off on real uplinks to a switch you control - and 802.3ad
is the one that negotiates, which makes it both the safest aggregate
and the one that requires the switch side to be configured to match.
Monitoring the members is as important as the mode. The default link
watcher is MII - the carrier state the NIC itself reports, polled every
MIIMonitorSec. MII sees a pulled cable but not a switch port that
silently stopped forwarding; the alternative is ARP monitoring
(ARPIntervalSec= with ARPIPTargets= addresses in networkd's
[Bond]), which
proves the path end to end at the price of periodic ARP traffic. The
lab uses MII at 100 ms, a reasonable production value as well.
19.4.2. Configuring a Persistent Bond and Upper-Layer Interfaces
The bond network rides rtclient's and rtserver's third and fourth
interfaces, 192.168.223.0/24. Three files build it - the bond device,
the members' file, and the bond's own address file:
# /etc/systemd/network/40-ch19-bond0.netdev
[NetDev]
Name=bond0
Kind=bond
[Bond]
Mode=active-backup
MIIMonitorSec=100ms
# /etc/systemd/network/40-ch19-bond0.network
[Match]
Name=bond0
[Network]
Address=192.168.223.10/24
The members' file deserves one deliberate piece of staging. In
active-backup mode the bonding driver makes whichever member attaches
first the active slave, and when both members are configured in the
same pass, the attach order is not predictable. Start with a version
that matches only eth3, so the initial active member is a choice
rather than a race:
# /home/john/debian-handbook/routing/bond-members.network (first version)
[Match]
Name=eth3
[Network]
Bond=bond0
[Link]
RequiredForOnline=no
One [Match] section ends up covering both members; this first version
deliberately admits only one. As with bridge ports, the member file
contains no address: enslaving an interface discards whatever
addresses it held, and the bond's own file is the only place the
network's address belongs. RequiredForOnline=no on the members keeps
systemd-networkd-wait-online from treating a member's carrier state
as boot-critical; the bond decides readiness. Install the three files
on rtclient, as john:
$ sudo install -m 0644 bond0.netdev /etc/systemd/network/40-ch19-bond0.netdev
$ sudo install -m 0644 bond-members.network /etc/systemd/network/40-ch19-bond-members.network
$ sudo install -m 0644 rtclient-bond0.network /etc/systemd/network/40-ch19-bond0.network
$ sudo networkctl reload
$ sudo networkctl reconfigure eth3 bond0
All silent. The bonding driver publishes its own state in
/proc/net/bonding/<name>, and that file is the reference view - mode,
active slave, per-member MII status and failure counts in one place.
Read it, on rtclient as john:
$ cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v6.12.86+deb13-amd64
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth3
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Peer Notification Delay (ms): 0
Slave Interface: eth3
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 52:54:00:e4:48:0b
Slave queue ID: 0
One member, one slave block, and eth3 is active because it attached
first - the only member there was. Now widen the match to the file's
final form:
# /home/john/debian-handbook/routing/bond-members.network (final version)
[Match]
Name=eth3 eth4
[Network]
Bond=bond0
[Link]
RequiredForOnline=no
Put the widened file in place of the first and apply it, on rtclient, as john:
$ sudo install -m 0644 bond-members.network /etc/systemd/network/40-ch19-bond-members.network
$ sudo networkctl reload
$ sudo networkctl reconfigure eth4
All silent again. Read the state file once more, on rtclient as john:
$ cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v6.12.86+deb13-amd64
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth3
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Peer Notification Delay (ms): 0
Slave Interface: eth3
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 52:54:00:e4:48:0b
Slave queue ID: 0
Slave Interface: eth4
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 52:54:00:c8:e6:74
Slave queue ID: 0
eth4 joined as the standby - the bond already had an active member,
and active-backup never re-elects on its own. The whole staged
sequence, with rtserver's own address file (192.168.223.20 in its
40-ch19-bond0.network), goes to rtserver the same way; the .netdev
and members files are identical on both hosts. Inspect what was built,
on rtclient as john:
$ ip -d link show bond0
14: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
link/ether be:ae:e3:50:43:76 brd ff:ff:ff:ff:ff:ff promiscuity 0 allmulti 0 minmtu 68 maxmtu 65535
bond mode active-backup active_slave eth3 miimon 100 updelay 0 downdelay 0 peer_notify_delay 0 use_carrier 1 arp_interval 0 arp_missed_max 2 arp_validate none arp_all_targets any primary_reselect always fail_over_mac none xmit_hash_policy layer2 resend_igmp 1 num_grat_arp 1 all_slaves_active 0 min_links 0 lp_interval 1 packets_per_slave 1 lacp_active on lacp_rate slow coupled_control on ad_select stable tlb_dynamic_lb 1 addrgenmode eui64 numtxqueues 16 numrxqueues 16 gso_max_size 65536 gso_max_segs 65535 tso_max_size 65536 tso_max_segs 65535 gro_max_size 65536 gso_ipv4_max_size 65536 gro_ipv4_max_size 65536
The detail line is the bond's whole configuration in one place:
mode active-backup, active_slave eth3 (currently sending),
miimon 100 (the MII poll interval), and the defaults for everything
else. The address and the members:
$ ip -br addr show bond0
bond0 UP 192.168.223.10/24 fe80::bcae:e3ff:fe50:4376/64
$ ip -br link show type bond_slave
eth3 UP be:ae:e3:50:43:76 <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP>
eth4 UP be:ae:e3:50:43:76 <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP>
type bond_slave filters to exactly the members, and both carry the
SLAVE flag and the bond's MAC - one device, from the network's point
of view, on two wires. Traffic flows, on rtclient as john:
$ ping -c 2 192.168.223.20
PING 192.168.223.20 (192.168.223.20) 56(84) bytes of data.
64 bytes from 192.168.223.20: icmp_seq=1 ttl=64 time=0.720 ms
64 bytes from 192.168.223.20: icmp_seq=2 ttl=64 time=0.414 ms
--- 192.168.223.20 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1019ms
rtt min/avg/max/mdev = 0.414/0.567/0.720/0.153 ms
19.4.3. Testing Failover and Inspecting Member State
The state file at the end of Section 19.4.2 is the healthy baseline:
eth3 active, eth4 the standby, both reporting carrier and zero
failures. The interesting readings come after something breaks. Take
the active member's link away - administratively, which stands in
for a cable pull exactly as far as the driver's MII watcher is
concerned - on rtclient, as john:
$ sudo ip link set eth3 down
The command is silent. With miimon 100 the driver notices within a
tenth of a second and swaps:
$ ping -c 2 192.168.223.20
PING 192.168.223.20 (192.168.223.20) 56(84) bytes of data.
64 bytes from 192.168.223.20: icmp_seq=1 ttl=64 time=0.349 ms
64 bytes from 192.168.223.20: icmp_seq=2 ttl=64 time=0.285 ms
--- 192.168.223.20 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1027ms
rtt min/avg/max/mdev = 0.285/0.317/0.349/0.032 ms
Two packets, zero loss, no visible interruption. The proc file records both the swap and the reason, on rtclient as john:
$ cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v6.12.86+deb13-amd64
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth4
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Peer Notification Delay (ms): 0
Slave Interface: eth3
MII Status: down
Speed: Unknown
Duplex: Unknown
Link Failure Count: 1
Permanent HW addr: 52:54:00:e4:48:0b
Slave queue ID: 0
Slave Interface: eth4
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 52:54:00:c8:e6:74
Slave queue ID: 0
Currently Active Slave: eth4, eth3's MII status down, and - the
counter worth watching over time - Link Failure Count: 1. The brief
link view agrees about the member's state:
$ ip -br link show eth3
eth3 DOWN be:ae:e3:50:43:76 <BROADCAST,MULTICAST,SLAVE>
Note the flags: still SLAVE, no longer UP. Bring the member back,
on rtclient as john:
$ sudo ip link set eth3 up
Silent. Read the state once more:
$ cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v6.12.86+deb13-amd64
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth4
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Peer Notification Delay (ms): 0
Slave Interface: eth3
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 1
Permanent HW addr: 52:54:00:e4:48:0b
Slave queue ID: 0
Slave Interface: eth4
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 52:54:00:c8:e6:74
Slave queue ID: 0
eth3 is up again, but eth4 stays active - active-backup does not
fail back. The restored member rejoins the pool and waits; the next
failure of eth4 is what promotes it. If determinism matters more than
equal wear, the kernel's bond primary parameter names a member that
always takes the active role whenever it is healthy. Debian 13's
networkd exposes the companion reselection behavior in [Bond]
(PrimaryReselectPolicy=) but not primary= itself, so a fixed
primary is a runtime setting through sysfs
(/sys/class/net/bond0/bonding/primary, not persisted by any
.netdev) or the job of whatever writes the bond for you. Neither the
swap nor the restore required
any routing change: the bond's address never moved, which is precisely
why upper layers - the routes, the DNS, the tunnels later in this
chapter - never noticed.