Setting up channel bonding on Ubuntu 16.04

On Ubuntu 16.04, all network interfaces,including the bond master and slaves, are configured manually in one file, /etc/network/interfaces. Figure 1 and Figure 2 show the configuration of the bonding master bond0 and the two slaves eth1 and eth2:

Figure 1. Example: Ubuntu 16.04--Configuration of a bonding master
# bond0 is the bonding NIC and can be used like any other normal NIC.
# bond0 is configured using static network information.
auto bond0
iface bond0 inet static
address 192.0.2.0
Netmask 255.255.255.0

bond-mode active-backup
bond-miimon 1000
bond-slaves none
bond-fail-over-mac 1

The bonding master is assigned a static IP address. The bonding options, such as bond-mode and bond-miimon, are added to the bond master’s interface. In this example, the bonding interface is in active-backup mode and has a MII monitor with a 1000-millisecond interval.

The same file also contains the configuration information for the slaves eth1 and eth2, under different interface names, as shown in Figure 2:

Figure 2. Example: Ubuntu 16.04--Configuration of bonding slaves
#eth1 is manually configured, and slave to the "bond0" bonded NIC
auto eth1
iface eth1 inet manual
hwaddress 02:00:00:87:95:e6
bond-master bond0
bond-primary eth1
#eth2 is manually configured, and slave to the "bond0" bonded NIC
auto eth2
iface eth2 inet manual
hwaddress 02:00:00:0f:ed:eb
bond-master bond0
The slave devices are manually configured. For each slave:
hwaddress
Specifies the MAC address.
bond-master
Identifies the master device. (This allows the bonding driver to combine the slaves to their master device.)
bond-primary
Specifies the primary slave device.
Note: If a particular slave device should be set as primary slave, the bond-primary directive needs to be part of the slave description rather than part of the master description. (If you include this option in the master section, it will be ignored.)