Bonding network interfaces for redundancy

Running multiple services across multiple machines and implementing appropriate HA methods ensure a high degree of tolerance to failure within our environment. But if it's the physical network that fails and not the service, outages will occur if traffic cannot flow to and from that service. Adding in Network Interface Card (NIC) bonding (also known as teaming or link aggregation) can help alleviate these issues by ensuring traffic flows through diverse routes and switches as appropriate.

Getting ready

NIC bonding requires coordination between system administrators and the network administrators who are responsible for the switches. There are various methods available for NIC bonding. The method presented here is active-passive mode, which describes that traffic will normally flows through a single switch, leaving the other teamed NIC to take no traffic until it is required.

How to do it...

Setting up NIC bonding in Ubuntu 14.04 requires an extra package installation to allow bonding. We set an NIC bond by following these steps:

  1. We install the ifenslave package in the usual manner, as follows:
    sudo apt-get update
    sudo apt-get install ifenslave
    
  2. With the ifenslave package installed, we simply configure networking as normal in Ubuntu but add in the required elements for bonding. To do this, we edit the /etc/network/interfaces file with the following contents (for active-passive mode bonding). Here, we're bonding eth1 and eth2 to give us bond0 with an address of 172.16.0.111:
    auto eth1
    iface eth1 inet manual
      bond-master bond0
      bond-primary eth1 eth2
    
    auto eth2
    iface eth2 inet manual
      bond-master bond0
      bond-primary eth1 eth2
    
    auto bond0
    iface bond0 inet static
      address 172.16.0.111
      netmask 255.255.0.0
      network 172.16.0.0
      broadcast 172.16.255.255
      bond-slaves none
      bond-mode 1
      bond-miimon 100
  3. To ensure that the correct bonding mode is used, we add the following contents into /etc/modprobe.d/bonding.conf. This describes an active/passive bond (mode=1) with a monitoring interval of 100 milliseconds:
    alias bond0 bonding
    options bonding mode=1 miimon=100
  4. We can now restart our networking, which in turn will bring up our bonded interface with the required IP address:
    sudo service networking restart
    

How it works...

Bonding network interfaces in Ubuntu to cater to a switch failure is relatively straightforward. This is achieved by providing the coordination with how the switches are set up and configured. With different paths to different switches configured and each network interface going to separate switches, a high level of fault tolerance to network-level events, such as a switch failure, can be achieved.

To do this, we configure our bonding in the traditional /etc/network/interfaces file under Ubuntu, but we specify which NICs are teamed with which bonded interface. Each bonded interface configured has at least a unique pair of interfaces assigned to it, and then we configure that bonded interface, bond0, with the usual IP address, netmask, and so on. We tag a few options specifically to notify Ubuntu that this is a bonded interface of a particular mode.

To ensure the bonding module that gets loaded as part of the kernel has the right mode assigned to it, we configure the module in /etc/modprobe.d/bonding.conf. When the bonding module loads along with te network interface, we end up with a server that is able to withstand isolated switch failures.

See also

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset