CSR Labs - High Availability with home hardware

Network redundancy on Raspberry Pi with ifenslave

Raspberry Pi NIC bonding

We have already seen the benefits of having network redundancy on a small computer such as the Raspberry Pi in this article. You definitely want to check it out before proceeding.

Using a dual NIC (Network Interface Card) system with ifenslave is a way to create a bonded NIC, which can provide additional network redundancy and failover capabilities. Ifenslave is a Linux kernel module that allows multiple NICs to be combined into a single bonded interface, so that they appear as a single NIC to the system.

When using ifenslave with a dual NIC system, the two NICs are configured as slaves to a virtual NIC known as the "bonded NIC". The two physical NICs will continue to function independently, however, the bonded NIC will be seen as a single NIC, this way the system will use the bonded NIC as the default NIC.

It is important to note that the configuration of the bond interface and the NICs should match, such as the same speed, duplex and MTU (Maximum Transmission Unit) configuration. Also, the network switch that connects to these NICs should support the NIC bonding and be configured accordingly; however, in my tests, I observed that even a cheap home switch worked properly with bonding configured on a Raspberry Pi.

Install and configure ifenslave on a Raspberry Pi

This guide assumes that a Raspberry Pi has been installed with OS Lite as per this guide and that DHCP has been disabled. In my tests, I could not make it work if DHCP was enabled and the Raspberry Pi NIC was configured with a dynamic IP address.

Install ifenslave

sudo apt update
sudo apt upgrade
sudo apt install ifenslave


Edit the file modules.conf to add the bonding kernel module, just type bonding at the end of the file

sudo nano /etc/modules-load.d/modules.conf

Edit modules.conf


Reboot the Raspberry Pi

sudo reboot


Verify that the kernel module has been loaded

sudo lsmod | grep bonding

bonding kernel module loaded


Assuming that DHCP has already been disabled, edit the interfaces config file

sudo nano /etc/network/interfaces


and make it looking like this, ajusting the IP addresses according to your network settings.
The addresses showed in the configuration below are for example purposes only.

auto lo
iface lo inet loopback

auto bond0
iface bond0 inet static
    bond-mode active-backup
    bond-fail_over_mac active
    bond-slaves eth0 eth1
    bond-primary eth0
    bond-primary_reselect always
    bond-miimon 250
    bond-downdelay 200
    bond-updelay 200


Reboot the Raspberry Pi

sudo reboot


If everything went well, your Raspberry Pi should still be reachable at the usual IP address.
You can check the bonding status with this command

cat /proc/net/bonding/bond0

bonding kernel module status

Let's do a test to validate redundancy. From another machine on the same network, try to set a continuous ping to the Raspberry Pi IP address.



If using a Windows machine the command would be

ping -t


Now try to unplug one cable at a time. You will see that the ping never stops, meaning that your Raspberry Pi has achieved network redundancy!


Support this blog

Please consider making a donation if you liked my blog and found it useful for your project.
It will support me in producing fresh articles and conducting more hardware testing.

PcbWay partnership program


  1. GitHub
  2. Twitter