INTRODUCTION.

bond2

This guide is a reference for myself on how to create a Ethernet Bonding in Linux, ‘bonding’ is connecting  two (or more) physical ethernet interfaces together to look and act as a single interface under Linux

Bonding  is a computer networking arrangement in which two or more network interfaces on a host computer are combined for redundancy or increased throughput.
mode=0 (Balance-rr) – This mode provides load balancing and fault tolerance.
mode=1 (active-backup) – This mode provides fault tolerance.
mode=2 (balance-xor) – This mode provides load balancing and fault tolerance.
mode=3 (broadcast) – This mode provides fault tolerance.
mode=4 (802.3ad) – This mode provides load balancing and fault tolerance.
mode=5 (balance-tlb) – Prerequisite: Ethtool support in the base drivers for retrieving the speed of each slave.
mode=6 (Balance-alb) – Prerequisite: Ethtool support in the base drivers for retrieving the speed of each slave.

 

INSTALLATION

This example assumes you have two interfaces and want to use them in a ‘fail-over’ setup, where if one cable dies, the kernel will automatically switch to using the other cable.. This setup is quite common on server hardware.

In /etc/modules.conf on a 2.4.x kernel, or in /etc/modprobe. on a 2.6.x kernel, the /etc/modprobe.conf has been deprecated in RedHat / CentOS 6, the process of bonding network interfaces has changed a bit.
Now instead of defining your bond in your /etc/modprobe.conf, you define it in /etc/modprobe.d/bonding.conf

 

We’ll be using mode=6 (Balance-alb)
Append the following onto the end out your modprobe config file

 

#vi /etc/modprobe.d/bonding.conf

Alias bond0  bonding

Options bond0 mode=6 miimon=100

You need the following files in /etc/sysconfig/network-scripts/ :

ifcfg-bond0

ifcfg-eth0

ifcfg-eth1

 

ifcfg-eth0 and ifcfg-eth1 should look similar to the following:

 

DEVICE=eth0

USERCTL=no

ONBOOT=yes

MASTER=bond0

SLAVE=yes

BOOTPROTO=none

MII_NOT_SUPPORTED=yes

The DEVICE= section should reflect the interface the file relates to (ifcfg-eth1 should have DEVICE=eth1). The MASTER= section should indicate the bonded interface to be used. Assign both ethernet devices to bond0.

 

The bond0 file contains the actual IP address information:

DEVICE=bond0

IPADDR=192.168.31.1

NETMASK=255.255.255.0

ONBOOT=yes

BOOTPROTO=none

USERCTL=no

MII_NOT_SUPPORTED=yes

 

Simply restarting the network service ‘service network restart’ should present you with a new ‘bond0’ interface. This is the interface you should see traffic going in and out of if youwere to tcpdump the interface.

You will also notice (using /sbin/ifconfig) that all of the ethX interfaces are also up, and also have IP addresses.

 

In this example, we are using the fail-over mode. The eth device without NOARP is the current active SLAVE. You may notice that both ethX interfaces have high traffic counters. This is because the system has been up for around 200 days and at some point the interfaces swapped status.