A Comprehensive Guide to Linux Dual NIC Bonding Configuration (CentOS 7/8) for High Availability Servers

Hello everyone, I am Derek, focusing on practical operations, cutting-edge technology analysis, and career growth stories. If you are interested in “practical operation skills”, “popular interpretations of new technologies”, or “real workplace advancement experiences”, feel free to follow and share, let’s avoid detours on the technical road together~

In a production environment, network connectivity is the lifeline. Whether it’s a database, web service, or virtualization platform, once a network card failure causes the server to go offline, the impact is often “cascading”. To prevent a single network card from becoming a single point of failure, dual NIC bonding has become the most reliable practice: integrating two physical network cards into one logical interface to achieve redundancy and high availability.

This article is based on CentOS 7/8 and explains the most commonly used and hassle-free mode=1 active-backup configuration.

1. What is Dual NIC Bonding?

Dual NIC bonding is an aggregation technology provided by the Linux kernel, which enhances network reliability by virtualizing multiple network cards into one logical network card.

It has two main values:

  • Redundancy and Fault Tolerance: Automatically switches to the backup network card when the primary network card goes down, ensuring uninterrupted service.
  • Load Capacity: Some modes support traffic distribution or link aggregation, improving bandwidth utilization.

Common Modes Overview

A Comprehensive Guide to Linux Dual NIC Bonding Configuration (CentOS 7/8) for High Availability Servers

This article focuses on mode=1: simple configuration, best compatibility, and no need to make any adjustments to the switch.

2. Preparation Before Configuration

1. Confirm the number of network cards: At least two physical network cards (e.g., eth0, eth1 or ens33, ens192).

2. Obtain root privileges: All operations must be executed as root.

3. Check the network card names:

ip addr

4. CentOS 7/8 enables NetworkManager by default, but bonding is recommended to use the traditional network service, so NetworkManager needs to be disabled.

3. Start Configuration (Core Steps)

1. Disable NetworkManager (Common for CentOS 7/8)

systemctl stop NetworkManager
systemctl disable NetworkManager
systemctl status NetworkManager

2. Create bond0 Logical Network Card

Edit the configuration file:

vi /etc/sysconfig/network-scripts/ifcfg-bond0

Write the following content (replace IP/gateway/DNS as needed):

TYPE=bond
DEVICE=bond0
NAME=bond0
BOOTPROTO=none

IPADDR=192.168.1.10
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=223.5.5.5
DNS2=223.6.6.6

ONBOOT=yes
USERCTL=no

BONDING_OPTS="mode=1 miimon=100"

miimon=100: checks the link status every 100ms.

3. Configure Two Physical Network Cards as Slave Interfaces

Network Card eth0:

vi /etc/sysconfig/network-scripts/ifcfg-eth0

Content:

TYPE=Ethernet
BOOTPROTO=none
NAME=eth0
DEVICE=eth0
MASTER=bond0
SLAVE=yes
ONBOOT=yes
USERCTL=no

Network Card eth1:

TYPE=Ethernet
BOOTPROTO=none
NAME=eth1
DEVICE=eth1
MASTER=bond0
SLAVE=yes
ONBOOT=yes
USERCTL=no

4. Bonding Module Load Configuration (Optional but Recommended)

vi /etc/modprobe.d/bonding.conf

Write:

alias bond0 bonding

5. Restart Network Service

systemctl restart network

If errors occur, check for spelling mistakes in the network card files.

4. Verify if Bonding is Effective (Key)

1. Check Bonding Status

cat /proc/net/bonding/bond0

Successful indicators should include:

  • Bonding Mode: fault-tolerance (active-backup)
  • Lists two slave network cards (e.g., eth0, eth1)
  • One marked as Active Slave
  • The other as Backup Slave

2. Check bond0 IP

ip addr show bond0

3. Test Primary-Backup Switching (Recommended)

For example, if eth0 is the primary network card:

ifdown eth0

Check again:

cat /proc/net/bonding/bond0

If eth1 automatically becomes Active Slave, it indicates the switch is normal.

5. Final Thoughts

Dual NIC bonding is crucial in server deployment, especially in the following scenarios:

  • Core business systems
  • Database nodes
  • Virtualization hosts
  • Storage/backup servers

Using mode=1 active-backup mode maximizes the avoidance of network single points of failure, and requires no changes to the switch, making it the most cost-effective high-availability network solution.

If you need to expand bandwidth, you can use mode=4 (LACP), but it requires switch support.

ENDImportant Reminder

🔴 Because of your attention and feedback, sharing becomes more meaningful ❤️.

✨ If you want to see more heartfelt articles in the future, don’t forget to follow, give a thumbs up, and share with friends for mutual encouragement.

Leave a Comment