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.
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.
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:
ifenslave
package in the usual manner, as follows:sudo apt-get update sudo apt-get install ifenslave
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
/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
sudo service networking restart
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.