Bonding Network Interfaces in CentOS 6

Overview

Bonding is the ability to take two or more network interfaces and present them as one to a client. Depending on the method you use, the bond can create different types of connections. You can, for example, create an aggregate channel to double or even triple your total bandwidth; create a fault tolerant connections to improve server reliability; or load balance connections to handle more requests and to improve response times.

Some of the more advanced bonding methods, like channel aggregation, require switches that support IEEE 802.3ad dynamic link aggregation policy. However, simple load balancing and fault tolerance can be done without.

Server Configuration

To make it easier for you to follow along, the following configuration will be used in this tutorial.

TABLE1Lab server configuration
Hostname Network Interface MAC Address IP Address Netmask Gateway
SERVER01 ETH0 00:1F:29:E6:EB:2A 172.30.0.34 255.255.255.0 172.30.0.1
ETH1 00:26:55:35:24:FE

It’s important that you record the MAC address (hardware address) of every interface. Although not required, it is best practice to assign a MAC address to each bond slave. Without doing so, you cannot confidently unplug an interface and know which slave will be offline, potentially causing a service outage.

Prepare the Interfaces

Before we configure the type of bond we’ll be using, we need to prepare the interfaces first. This envolves creating the bond0 configuration file, and then modifying the existing configurations files for each of your physical network interfaces. In this lab, there are only two.

The steps for configuring the different bond types can be found after this section. Choose one and then follow the instructions.

Create the Bonded Interface

This is the interface your clients will be connecting to.

  1. Create the configuration file for the first bond, bond0.
    touch /etc/sysconfig/network-scripts/ifcfg-bond0
  2. Open the file in a text editor.
    nano /etc/sysconfig/network-scripts/ifcfg-bond0
  3. Add the following lines to the file.
    DEVICE=bond0
    IPADDR=172.30.0.34
    NETMASK=255.255.255.0
    GATEWAY=172.30.0.1
    ONBOOT=yes
    BOOTPROTO=none
    USERCTL=no
  4. Save your changes and exit the text editor.

Configure Slave 1

  1. Open the configuration file for the first interface, eth0, into a text editor.
    nano /etc/sysconfig/network-scripts/ifcfg-eth0
  2. Modify the configuration file to look like the following, replacing the highlighted parts to match your environment.
    DEVICE=eth0
    ONBOOT=yes
    BOOTPROTO=none
    HWADDR=00:1F:29:E6:EB:2A
    USERCTL=no
    MASTER=bond0
    SLAVE=yes

Configure Slave 2

  1. Open the configuration file for the second interface, eth1, into a text editor.
    nano /etc/sysconfig/network-scripts/ifcfg-eth1
  2. Modify the configuration file to look like the following, replacing the highlighted parts to match your environment.
    DEVICE=eth1
    ONBOOT=yes
    BOOTPROTO=none
    HWADDR=00:26:55:35:24:FE
    USERCTL=no
    MASTER=bond0
    SLAVE=yes

Configure a Fault Tolerant Bond

Also called an Active-Passive connection, this bond type will protect you from a failed physical network interface and, depending on your Ethernet configuration, a failure on your physical network.

  1. If it doesn’t already exist, create a new file called bonding.conf in /etc/modprobe.d
    touch /etc/modprobe.d/bonding.conf
  2. Open the file in a text editor.
    nano /etc/modprobe.d/bonding.conf
  3. Add the following lines to the file.
    alias bond0 bonding
    options bond0 miimon=80 mode=1
    TABLE2Bonding.conf options
    bond0 Name of the bonded interface being created.
    miimon Defines how often, in milli-seconds, the interface is checked to see if it is still active.
    mode Type of bond being created.
  4. Save your changes and exit the text editor.

Create Round-Robin Bond

Robin-Robin load balancing splits the connections between the two slaves evenly. The incoming connections alternate between the active slaves, taking the load off of each other, to improve request time.

  1. If it doesn’t already exist, create a new file called bonding.conf in /etc/modprobe.d
    touch /etc/modprobe.d/bonding.conf
  2. Open the file in a text editor.
    nano /etc/modprobe.d/bonding.conf
  3. Add the following lines to the file.
    alias bond0 bonding
    options bond0 miimon=80 mode=0
    TABLE3bonding.conf options
    bond0 Name of the bonded interface being created.
    miimon Defines how often, in milli-seconds, the interface is checked to see if it is still active.
    mode Type of bond being created.
  4. Save your changes and exit the text editor.

Create Aggregate Bond

Network aggregation combines the target network interfaces to create one large network interface. This will multiple the available bandwidth of the server’s network connection by the of NICs installed.

For this bond to work, you need your interfaces to be connected to a switch that supports IEEE 802.3ad dynamic link aggregation policy. Also, the ports have the feature enabled.

  1. If it doesn’t already exist, create a new file called bonding.conf in /etc/modprobe.d
    touch /etc/modprobe.d/bonding.conf
  2. Open the file in a text editor.
    nano /etc/modprobe.d/bonding.conf
  3. Add the following lines to the file.
    alias bond0 bonding
    options bond0 miimon=80 mode=4
    TABLE4 Рbonding.conf options
    bond0 Name of the bonded interface being created.
    miimon Defines how often, in milli-seconds, the interface is checked to see if it is still active.
    mode Type of bond being created.
  4. Save your changes and exit the text editor.

Restart the Network Services

Our bond is created. It’s time to restart the network services to apply our configuration.

  1. Restart the sevices
    services network restart