Linux Ethernet Bonding

1.1 Ethernet Bonding

Ethernet Bonding (NIC Teaming) allows you to have two NICs bonded together to appear as if they are the same physical device. Also, you can aggregate multiple ports into a single group, effectively combining the bandwidth into a single connection.

1.2 Pre-requisites

To bond two Ethernet interfaces, the following are necessary –

  1. mii-tool support to check the status of the NIC
  2. ethtool support for retrieving the speed and duplex of each slave.
  3. Most importantly, verify if the kernel supports Ethernet Bonding

                #  modprobe –list | grep bonding

/lib/modules/2.6.26-2-686/kernel/drivers/net/bonding/bonding.ko

— represents that the kernel support ethernet bonding.

1.3 Ethernet Bonding Configuration

Before attempting to bond two NICs, it is highly recommended that you verify the integrity and functionality of each NIC on its own.

  Step #1: Create a bond0 configuration file

Red Hat Linux stores network configuration in

/etc/sysconfig/network-scripts/ directory.

First, create bond0 config file:

# vi /etc/sysconfig/network-scripts/ifcfg-bond0

Append following lines to it:

DEVICE=bond0
IPADDR=<IP ADDRESS>
NETWORK=<Network ID>
NETMASK=<Netmask Value>
USERCTL=no
BOOTPROTO=none
ONBOOT=yes

Save file and exit to shell prompt.

Step #2: Modify eth0 and eth1 config files:

Open both configuration using vi text editor and make sure file read as follows for eth0 interface

# vi /etc/sysconfig/network-scripts/ifcfg-eth0

Modify/append directive as follows:

DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

Open eth1 configuration file using vi text editor:

# vi /etc/sysconfig/network-scripts/ifcfg-eth1

Make sure file read as follows for eth1 interface:

DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

Save file and exit to shell prompt.

Step # 3: Load bond driver/module

Make sure bonding module is loaded when the channel-bonding interface (bond0) is brought up. You need to modify kernel modules configuration file:

# vi /etc/modprobe.conf

Append following two lines:

alias bond0 bonding
options bond0 mode=1 miimon=100

Save file and exit to shell prompt.

mode – Specifies  the bonding policy. The default is mode 0 – balance-rr (round robin).

Here, we are implementing mode 0 for fail-over operation.

Active-backup policy – Only one slave in the bond is active. A different slave becomes active if, and only if, the active slave fails. This mode provides fault tolerance.

Step # 4: Test configuration

First, load the bonding module:

# modprobe bonding

Restart networking service in order to bring up bond0 interface:

# service network restart

2. Benefits of Bonding

Bonding support under Linux is part of a high availability solution.

It has the following features.

  • redundant links
  • fault tolerance and
  • load balancing.

The behavior of the bonded interfaces depends upon the mode.

You can set up your bond interface according to your needs.

You can have the following bonding types:
mode=0 (balance-rr)
Round-robin policy: Transmit packets in sequential order from the first available slave through the last. This mode provides load balancing and fault tolerance.

mode=1 (active-backup)
Active-backup policy: Only one slave in the bond is active. A different slave becomes active if, and only if, the active slave fails. This mode provides fault tolerance.

mode=2 (balance-xor)
XOR policy: Transmit based on [(source MAC address XOR’d with destination MAC    address) modulo slave count]. This mode provides load balancing and fault tolerance.

mode=3 (broadcast)
Broadcast policy: transmits everything on all slave interfaces. This mode provides fault tolerance.

mode=4 (802.3ad)
IEEE 802.3ad Dynamic link aggregation. Creates aggregation groups that share the same speed and duplex settings.

mode=5 (balance-tlb)
Adaptive transmit load balancing: The outgoing traffic is distributed according to the current load on each slave. Incoming traffic is received by the current slave. If the receiving slave fails, another slave takes over the MAC address of the failed receiving slave.