How to Configure Linux Network Bonding via nmcli

The Need for Network Resilience

If you are deploying a critical database server or a high-traffic web server on Linux, relying on a single physical network interface card (NIC) is a single point of failure. If the ethernet cable is accidentally unplugged, or if the switch port dies, your server immediately drops off the network.

To ensure high availability, enterprise Linux servers utilize Network Bonding (also known as Teaming or Link Aggregation). Bonding allows you to take two physical network interfaces (e.g., eth0 and eth1) and combine them into a single logical interface (e.g., bond0). The server is assigned a single IP address on bond0. If eth0 suddenly loses power, the Linux kernel seamlessly routes all traffic through eth1 without dropping a single active TCP connection.

While you can configure bonding by manually editing network scripts, modern Linux distributions utilize NetworkManager. The fastest and most reliable way to configure bonding is through the nmcli command-line utility.

Step 1: Identifying the Physical Interfaces

Before creating the bond, you must verify the names of your physical network cards. Run the following command:

nmcli device status

You should see two disconnected ethernet devices, such as enp3s0 and enp4s0.

Step 2: Creating the Master Bond Interface

First, we create the logical “master” interface (bond0). This is the interface that will actually hold the IP address.

We will use the active-backup mode, which provides strict failover redundancy.

sudo nmcli connection add type bond con-name bond0 ifname bond0 bond.options "mode=active-backup,miimon=100"
  • type bond: Defines this as an aggregation interface.
  • mode=active-backup: One interface is active; the other waits in standby.
  • miimon=100: Instructs the kernel to monitor the physical link state every 100 milliseconds. If the active link fails, the failover occurs almost instantly.

Step 3: Adding the Slave Interfaces

Now, you must bind your physical network cards (the slaves) to the master bond0 interface.

Add the first physical interface:

sudo nmcli connection add type ethernet slave-type bond con-name bond0-slave1 ifname enp3s0 master bond0

Add the second physical interface:

sudo nmcli connection add type ethernet slave-type bond con-name bond0-slave2 ifname enp4s0 master bond0

Step 4: Assigning an IP Address

With the physical cards bound to the logical interface, you can now assign your static IP address to the bond0 master interface.

sudo nmcli connection modify bond0 ipv4.addresses "192.168.1.50/24"
sudo nmcli connection modify bond0 ipv4.gateway "192.168.1.1"
sudo nmcli connection modify bond0 ipv4.dns "8.8.8.8"
sudo nmcli connection modify bond0 ipv4.method manual

Step 5: Activating the Bond

To bring the new highly available network configuration online, simply bring up the master connection. NetworkManager will automatically bring up the associated slave interfaces.

sudo nmcli connection up bond0

You can verify the bond is active and examine which physical interface is currently handling traffic by reading the kernel proc file:

cat /proc/net/bonding/bond0

The output will clearly display the active interface and confirm the status of the backup link.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.