✦ For everyone, free.

Practical knowledge for real and everyday life

Home

Network Bonding

Network Bonding combines multiple network interfaces into a single logical connection, enhancing reliability and performance in Alpine Linux systems.

Network Bonding is a method used in computer networking to combine multiple network interfaces into a single logical interface. This technique increases bandwidth, provides redundancy, and improves network fault tolerance by aggregating the throughput of several physical network links or by enabling failover capabilities so that if one link fails, network connectivity persists through the other links.


Overview of Network Bonding

Network Bonding, sometimes referred to as link aggregation, NIC teaming, or trunking, allows multiple physical Ethernet interfaces to act as one. This is particularly useful in data centers and enterprise environments where high availability and higher data rates are critical.

Bonding presents a single network device to the operating system, which manages multiple underlying network interfaces transparently. This logical interface can be configured with IP addressing, routing, and other network settings just like a single NIC.


Key Benefits

  • Increased Bandwidth: By combining interfaces, the effective throughput can exceed the capacity of any single interface.
  • Redundancy and Failover: If one physical link or interface fails, bonded interfaces continue to operate using the remaining links, minimizing downtime.
  • Load Balancing: Network traffic can be distributed across interfaces to optimize performance.
  • Simplified Management: The system administrator manages one interface rather than multiple NICs.

Bonding Modes in Alpine Linux

Alpine Linux supports several bonding modes, each suited for different use cases and network environments. The mode determines how traffic is distributed and how failover is handled.

  1. Mode 0 (balance-rr): Round-Robin

    • Transmits packets sequentially across all interfaces.
    • Provides load balancing and fault tolerance.
    • Requires switch support for link aggregation.
  2. Mode 1 (active-backup): Active/Backup

    • Only one interface is active; others are backups.
    • If the active interface fails, a backup takes over.
    • Does not require special switch support.
  3. Mode 2 (balance-xor): XOR

    • Transmits based on XOR of source and destination MAC addresses.
    • Provides load balancing and fault tolerance.
    • Requires switch support.
  4. Mode 3 (broadcast): Broadcast

    • Sends all packets on all interfaces.
    • Provides fault tolerance but no load balancing.
  5. Mode 4 (802.3ad): Dynamic link aggregation (LACP)

    • Uses Link Aggregation Control Protocol (LACP).
    • Requires switch support.
    • Provides dynamic aggregation and load balancing.
  6. Mode 5 (balance-tlb): Adaptive transmit load balancing

    • Balances outgoing traffic based on load.
    • Incoming traffic is received by one interface.
    • Does not require switch support.
  7. Mode 6 (balance-alb): Adaptive load balancing

    • Includes transmit and receive load balancing.
    • Does not require switch support.
    • Uses ARP negotiation for receive balancing.

Configuration in Alpine Linux

In Alpine Linux, network bonding is typically configured through the /etc/network/interfaces file or using OpenRC scripts. The bonding kernel module bonding must be loaded.

Loading the Bonding Module

modprobe bonding

To load the module on boot, add the module name to /etc/modules:

bonding

Example Interface Configuration

Example of bonding two interfaces eth0 and eth1 in active-backup mode with a static IP:

auto bond0
iface bond0 inet static
    address 192.168.1.100
    netmask 255.255.255.0
    gateway 192.168.1.1
    bond-slaves eth0 eth1
    bond-mode active-backup
    bond-miimon 100
  • bond-slaves specifies the interfaces to bond.
  • bond-mode sets the bonding mode.
  • bond-miimon monitors link status every 100 milliseconds to detect failures.

Important Parameters

  • bond-miimon: Monitors link health at specified intervals (in milliseconds). If a link fails, failover can be triggered.
  • bond-downdelay / bond-updelay: Delays for link down/up events.
  • bond-lacp-rate: Sets the LACPDU transmission rate (fast or slow) for mode 4.
  • bond-primary: Specifies a preferred primary slave interface for active-backup mode.
  • bond-xmit_hash_policy: Determines transmit hash policy for load balancing (layer2, layer3+4, etc.).

Kernel Module and Drivers

The bonding feature is implemented as a kernel module named bonding. It acts as a virtual network interface that manages multiple physical NICs. When the bonding module is loaded, the kernel creates a new network interface, typically named bond0, which can then be configured like any standard network interface.


Network Switch Considerations

Certain bonding modes require support from connected network switches to function correctly:

  • Modes like balance-rr, balance-xor, and 802.3ad require the switch to support link aggregation or IEEE 802.3ad (LACP).
  • Modes such as active-backup and adaptive load balancing do not require special switch support and can be used with any switch.

Improper switch configuration can lead to network loops or degraded performance.


Monitoring and Troubleshooting

Bonded interfaces can be monitored using standard network tools:

  • cat /proc/net/bonding/bond0 displays the bonding status, mode, active interfaces, and link status.
  • ip link show bond0 shows the interface status.
  • System logs (dmesg or /var/log/messages) may provide bonding-related messages.

Use Cases

  • High Availability: Ensuring continuous network connectivity in case of hardware failure.
  • Increased Throughput: Aggregating bandwidth for heavy data transfer workloads.
  • Data Centers: Providing resilient and scalable network architecture.
  • Virtualization Hosts: Improving NIC utilization in hypervisors.

Summary of Bonding Modes Table

Mode NumberMode NameDescriptionRequires Switch SupportLoad BalancingFault Tolerance
0balance-rrRound-robin packet transmissionYesYesYes
1active-backupOne active, others standbyNoNoYes
2balance-xorXOR of MAC addressesYesYesYes
3broadcastTransmit on all interfacesNoNoYes
4802.3ad (LACP)Dynamic link aggregationYesYesYes
5balance-tlbAdaptive transmit load balancingNoYesYes
6balance-albAdaptive load balancing (transmit & receive)NoYesYes

Network Bonding in Alpine Linux is a powerful feature that enhances network performance and reliability by combining multiple physical interfaces into one logical interface, offering various modes tailored to different network environments and requirements. Proper configuration and understanding of bonding modes and switch compatibility are critical for effective deployment.