Skip to content

How to Use `nmcli` to Create NIC Bonding

How to Use nmcli to Create NIC Bonding

Table of Contents

  1. Introduction
  2. Step 1: Check Existing Network Interfaces πŸ–₯️
  3. Step 2: Create the Bond Interface πŸ”—
  4. Step 3: Add Slaves to the Bond Interface βž•
  5. Step 4: Configure IP Settings 🌐
  6. Step 5: Bring Up the Bonded Interface πŸ†™
  7. Step 6: Verify Your Setup βœ…
  8. Conclusion 🎯

1. Introduction

Network bonding (or NIC bonding) combines multiple network interfaces into one logical interface to improve redundancy and throughput. Let’s use nmcli to create NIC bonding on a Linux system! πŸš€


2. Step 1: Check Existing Network Interfaces πŸ–₯️

First, list all your network interfaces:

nmcli device status

πŸ” Identify the interfaces you want to bond (e.g., eth0, eth1).


3. Step 2: Create the Bond Interface πŸ”—

Create the bond interface using nmcli:

nmcli connection add type bond con-name bond0 ifname bond0 mode active-backup

Explanation:

  • con-name bond0: Name of the bonded connection.
  • ifname bond0: Name of the bonded interface.
  • mode active-backup: Bonding mode. You can choose modes like balance-rr, 802.3ad, etc.

4. Step 3: Add Slaves to the Bond Interface βž•

Add the identified interfaces as slaves to the bond:

nmcli connection add type ethernet con-name slave-eth0 ifname eth0 master bond0
nmcli connection add type ethernet con-name slave-eth1 ifname eth1 master bond0

πŸ”— This attaches eth0 and eth1 as slaves to the bond0 interface.


5. Step 4: Configure IP Settings 🌐

Assign an IP address to the bond:

nmcli connection modify bond0 ipv4.addresses 192.168.1.100/24
nmcli connection modify bond0 ipv4.method manual
nmcli connection up bond0

Replace 192.168.1.100/24 with the correct IP and subnet for your network.


6. Step 5: Bring Up the Bonded Interface πŸ†™

Activate the bond and its slaves:

nmcli connection up bond0
nmcli connection up slave-eth0
nmcli connection up slave-eth1

πŸŽ‰ Your bonded interface is now active!


7. Step 6: Verify Your Setup βœ…

Check if everything is working correctly:

nmcli connection show

You can also check the bonding details:

cat /proc/net/bonding/bond0

8. Conclusion 🎯

You’ve successfully created NIC bonding using nmcli! Your setup should now provide better network resilience and potentially increased throughput.