Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Configuring Network Interface Bonding in Linux

Tech 3

Network interface bonding in Linux aggregates multiple physical network interfaces into a single logical interface too enhance bandwidth, load balancing, and redundancy. This technique is essential in complex network environments for improving performance and availability.

Linux supports several bonding modes, each with distinct characteristics and use cases.

Alias Configuration Name English Name Chinese Name Description
bond0 balance-rr Round-robin policy 平衡轮询策略 Transmits packets sequentially across interfaces, providing load balancing and fault tolerance.
bond1 active-backup Active-backup policy 活动备份策略 Only one interface is active; if it fails, a backup takes over, offering fault tolerance. MAC address is externally visible.
bond2 balance-xor XOR policy 平衡策略 Selects transmission interface based on (source MAC XOR destination MAC) mod device count, providing load balancing and fault tolerance.
bond3 broadcast Broadcast policy 广播策略 Sends all packets to every interface, ensuring fault tolerance.
bond4 802.3ad IEEE 802.3ad Dynamic link aggregation IEEE 802.3ad 动态链接聚合 Creates an aggregation group with shared speed and duplex settings, requiring switch support for 802.3ad mode and driver-based speed/duplex retrieval.
bond5 balance-tlb Adaptive transmit load balancing 适配器传输负载均衡 Distributes outgoing traffic based on current load without special switch support; incoming traffic is handled by the current active interface.
bond6 balance-alb Adaptive load balancing 适配器负载均衡 Includes mode5 features with ARP negotiation for receive load balancing, intercepting ARP requests to use hardware addresses from slave devices.
  • Modes 0, 2, and 3 typically require static aggregation methods.
  • Modes 1, 5, and 6 do not need switch configuration; network cards can aggregate automatically.
  • Mode 4 requires 802.3ad support and switch configuration.

Active-Backup Mode

In this mode, only one network interface is active, with others as backups. If the active interface fails, a backup takes over, making it suitable for high-availability network connections.

Balance-RR (Round Robin) Mode

Packets are distributed in a round-robin fashion across all available interfaces. This mode provides load balancing but may not fully utilize bandwidth.

802.3ad (LACP) Mode

Utilizes the Link Aggregation Control Protocol (LACP) to bind multiple interfaces together, offering load balancing and redundancy. Switch support is required.

Balance-TLB (Transmit Load Balancing) Mode

Distributes packets based on current network traffic conditions, providing adaptive load balancing.

Balance-ALB (Adaptive Load Balancing) Mode

Learns optimal paths for packet transmission, suitable for dynamic network environments.

Configuration Steps on Linux Systems

Step 1: Install the ifenslave Tool

sudo apt-get install ifenslave

Step 2: Edit Network Configuration File

Modify the /etc/network/interfaces file to add bonding configurations:

# Network interfaces configuration
source /etc/network/interfaces.d/*

# Loopback interface
auto lo
iface lo inet loopback

# First slave interface
auto eth0
iface eth0 inet manual
    bond-master bond0

# Second slave interface
auto eth1
iface eth1 inet manual
    bond-master bond0

# Bonding interface
auto bond0
iface bond0 inet static
    address 192.168.1.100
    netmask 255.255.255.0
    gateway 192.168.1.1
    dns-nameservers 8.8.8.8 8.8.4.4
    slaves eth0 eth1
    bond-mode 1
    bond-miimon 100
    bond-lacp-rate 1

Step 3: Restart Network Services

sudo service networking restart

Configuration Steps on OpenWrt Systems

Check if necessary kernel components are installed:

opkg list | grep kmod-bonding

If not present, install kmod-bonding. In the latest official kernel version 5.15.162, this component is included by default. Older versions may require upgrading.

View current kernel version:

uname -r

Install link aggregation kernel module and LuCI graphical plugin:

opkg update
opkg install kmod-bonding
opkg install luci-proto-bonding

Offline installation using IPK packages:

After installation, reboot the system. The link aggregation feature will appear in the network interface configuration.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.