How to Bind Two NICs to a Single IP for High Availability on Linux
This guide explains how to bind two network interfaces into a single virtual NIC on Linux using the bonding driver, covering supported modes, detailed configuration files, command-line steps, verification commands, and practical tips for ensuring high‑availability without IP duplication.
To achieve network high availability, multiple NICs can be bonded into a virtual interface (bond) so that a single IP is used and failure of one NIC does not interrupt connections. Linux implements this via the bonding driver (called bonding, etherchannel, or team).
Bonding methods
Two main methods: bond and team. Below we focus on bond.
Supported bonding modes
Bond supports seven modes (0‑6). Commonly used are: mode=0: balance‑load with automatic failover, requires switch configuration. mode=1: active‑backup, no switch config needed. mode=6: balance‑load with failover, no switch config needed. Other modes: mode=2: XOR of MAC addresses, configurable via xmit_hash_policy . mode=3: broadcast to all slaves. mode=4: dynamic link aggregation (requires ethtool support and IEEE 802.3ad switch). mode=5: based on slave speed (requires ethtool support).
Configuration steps
# Load bonding module
modprobe --first-time bonding
lsmod | grep bonding
# Create /etc/sysconfig/network-scripts/ifcfg-bond1
DEVICE=bond1
TYPE=Bond
IPADDR=192.168.171.111
NETMASK=255.255.255.0
GATEWAY=192.168.171.2
DNS1=114.114.114.114
DNS2=8.8.8.8
USERCTL=no
BOOTPROTO=none
ONBOOT=yes
# Configure slave interfaces (ens33, ens36)
# Example for ens33
DEVICE=ens33
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=ens33
MASTER=bond1
SLAVE=yes
# Example for ens36 (similar)
# Load bonding options
echo "alias bond1 bonding
options bonding mode=1 miimon=200" > /etc/modules-load.d/bonding.conf
# Restart network
systemctl restart networkAfter configuration, the IP address is assigned only to bond1; the physical NICs have no IP. Verify with ip a show bond1 and cat /proc/net/bonding/bond1. If either slave goes down, traffic continues via the other.
Notes
On VMware Workstation, do not use ifdown on the slaves; instead disconnect the network adapter in the VM settings.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
