Sub topic 13
Aggregating Links on a Linux Server
This chapter assumes you know how LACP negotiates a bundle, what a hash policy does, and basic Linux ip commands. Here you apply those ideas on a server. Linux calls a link aggregation group a bond. In 802.3ad mode the bond speaks LACP, so it can bundle with the switch port channel from the earlier chapters.
How a bond maps to a port channel
The bond interface bond0 is the logical link. The physical NICs are its members, which Linux calls slaves in kernel documentation. The switch side must run LACP too, in active or passive mode.
Creating the bond
The commands below create the bond, add two NICs, and show its status.
ip link add bond0 type bond mode 802.3ad miimon 100 lacp_rate fast xmit_hash_policy layer3+4
ip link set eth0 down
ip link set eth0 master bond0
ip link set eth1 down
ip link set eth1 master bond0
ip link set bond0 up
cat /proc/net/bonding/bond0The options mean the following:
mode 802.3adselects LACP.miimon 100checks each member's link state every 100 ms.lacp_rate fastsends LACPDUs every second instead of every 30 seconds, so a dead partner is detected sooner.xmit_hash_policypicks the hash for outgoing frames.
A member must be down before you enslave it, which is why each NIC is brought down first.
Choosing the hash policy
| Policy | Hash inputs | Use when |
|---|---|---|
| `layer2` (default) | Source and destination MAC | Traffic goes to many different MACs |
| `layer2+3` | MAC and IP addresses | Many peers behind a single router MAC |
| `layer3+4` | IP addresses and TCP/UDP ports | Many connections between the same two hosts |
The policy affects only frames the server sends. The switch's own port-channel load-balance setting decides how return traffic is spread. You may need to tune both ends.
Reading the status
In /proc/net/bonding/bond0, check these fields:
- Bonding Mode should read
IEEE 802.3ad Dynamic link aggregation. - Partner Mac Address should be the switch's MAC.
00:00:00:00:00:00means no LACPDUs are arriving, so the switch is not running LACP on those ports. - Aggregator ID should be the same on every member. A member with a different ID has been placed in a separate bundle, usually because its partner information differs.
- MII Status should be
upfor the bond and for each member.
On the switch, show etherchannel summary should show the members flagged P (bundled).
Common mistakes
- The switch ports are configured
on(static) while the server runs LACP. The server never sees a partner, and the bundle fails. - Members have different speeds or duplex. LACP places mismatched members in separate aggregators, so only one set carries traffic.
- One flow still gets only one member's bandwidth. A bond raises total throughput across many flows, not the speed of a single flow.
Exercise
After you build bond0, /proc/net/bonding/bond0 shows Partner Mac Address 00:00:00:00:00:00, and the switch ports are set to channel-group 1 mode on. What is wrong, and what is the fix?
Show answer
Mode on is static aggregation, so the switch sends no LACPDUs and the Linux bond never learns a partner. Change the switch to channel-group 1 mode active (or passive). Then check that the Partner Mac Address shows the switch's MAC.