Ubuntu Network Bonding


Network bonding refers to the combination of network interfaces on one host for redundancy and/or increased throughput. Redundancy is the key factor: we want to protect our virtualized environment from loss of service due to failure of a single physical link.

We will configure our network cards in “active/backup” configuration. This is a network bonding fallback configuration which means if one of your network cards fails all of the traffic will be instantly switched to the other, still working network card.

1. Install required packages

[email protected]:~# apt-get update
[email protected]:~# apt-get install ifenslave

2. Edit /etc/modules file

Edit /etc/modules file and add “bonding” at the end of it.

[email protected]:~# cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with “#” are ignored.


3. Stop networking

[email protected]:~# /etc/init.d/networking stop

4. Edit /etc/network/interfaces file

Edit /etc/network/interfaces file and configure bonding interface bond0. You also need to change existing eth interfaces to be known as slaves of bond interface by adding “bond-master bond0” to their configuration. There are a couple of bond interface options explained below. Mind the bold text!

[email protected]:~# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet manual
bond-master bond0
bond-primary eth0

# The secondary network interface
auto eth1
iface eth1 inet manual
bond-master bond0

# Bonding interface configuration
auto bond0
iface bond0 inet static
bond-slaves eth0 eth1
bond-miimon 100
bond-mode active-backup

5. Modprobe bonding

[email protected]:~# modprobe bonding

6. Start networking

[email protected]:~# /etc/init.d/networking start

7. Check the status of network bonding

As we can see below, bonding was successfully configured in active-backup mode. Slave interfaces are eth0 and eth1.

[email protected]:~# cat /proc/net/bonding/bond0

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: eth0 (primary_reselect always)
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 08:00:27:a8:ab:ab
Slave queue ID: 0

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 08:00:27:de:fd:85
Slave queue ID: 0

7. Check ifconfig

Again we see that all interfaces are up and running and bond0 interface has the assigned IP address. Network bonding on Ubuntu Server is working as expected.