Introduction
Linux has powerful networking capabilities built into the kernel — bonding (NIC teaming), VLANs, and bridges allow you to build complex network topologies without any additional hardware. These are essential for hypervisors, routers-on-a-stick, and high-availability servers.
Linux Bonding (NIC Teaming)
Bonding combines multiple physical NICs into a single logical interface for redundancy or throughput.
Bonding Modes
| Mode | Name | Use Case |
|---|---|---|
| 0 | round-robin | Max throughput, no redundancy |
| 1 | active-backup | High availability, one active NIC |
| 2 | balance-xor | Load balance by XOR of MAC |
| 4 | 802.3ad (LACP) | True link aggregation, needs switch support |
| 5 | balance-tlb | Adaptive load balancing, no switch config |
| 6 | balance-alb | ALB + receive load balancing |
Setting Up Bonding (systemd-networkd)
Create /etc/systemd/network/bond0.netdev:
[NetDev]
Name=bond0
Kind=bond
[Bond]
Mode=active-backup
MIIMonitorSec=100ms
FailOverMACPolicy=activeCreate /etc/systemd/network/bond0.network:
[Match]
Name=bond0
[Network]
Address=192.168.1.10/24
Gateway=192.168.1.1
DNS=8.8.8.8Create member interfaces /etc/systemd/network/eth0.network:
[Match]
Name=eth0
[Network]
Bond=bond0Similarly for eth1. Then:
systemctl restart systemd-networkdSetting Up Bonding (legacy ifconfig/ip method)
# Load bonding module
modprobe bonding
# Create bond interface
ip link add bond0 type bond mode active-backup miimon 100
# Add slaves
ip link set eth0 master bond0
ip link set eth1 master bond0
# Bring up the bond
ip link set bond0 up
ip addr add 192.168.1.10/24 dev bond0
# Check bond status
cat /proc/net/bonding/bond0LACP (802.3ad) Setup
Requires switch configuration (portchannel/LAG):
# Server side
ip link add bond0 type bond mode 802.3ad lacp_rate fast miimon 100
ip link set eth0 master bond0
ip link set eth1 master bond0
# Switch side (Cisco IOS example)
interface range GigabitEthernet0/1-2
channel-group 1 mode active # LACP active
channel-protocol lacp
interface Port-channel1
no shutdownLinux VLANs
VLANs segment network traffic on a single physical interface.
# Load VLAN module
modprobe 8021q
# Create VLAN interface
ip link add link eth0 name eth0.10 type vlan id 10
ip link add link eth0 name eth0.20 type vlan id 20
# Assign IPs
ip link set eth0.10 up
ip link set eth0.20 up
ip addr add 192.168.10.1/24 dev eth0.10
ip addr add 192.168.20.1/24 dev eth0.20Persistent VLAN with systemd-networkd
# /etc/systemd/network/vlan10.netdev
[NetDev]
Name=vlan10
Kind=vlan
[VLAN]
Id=10# /etc/systemd/network/vlan10.network
[Match]
Name=vlan10
[Network]
Address=192.168.10.1/24Linux Bridges
A bridge acts as a virtual switch, connecting multiple interfaces at Layer 2.
# Create bridge
ip link add br0 type bridge
# Add interfaces to bridge
ip link set eth0 master br0
ip link set eth1 master br0
# Assign IP to bridge (not to individual interfaces)
ip link set br0 up
ip addr add 192.168.1.10/24 dev br0
# Enable STP on bridge
ip link set br0 type bridge stp_state 1Complete Hypervisor Network Stack
Typical KVM/libvirt setup with bonding + VLANs + bridges:
Physical NICs: eth0, eth1
→ bond0 (LACP/active-backup)
→ vlan10 (management)
→ br-mgmt (bridge for VMs using management VLAN)
→ vlan20 (production)
→ br-prod (bridge for production VMs)
→ vlan30 (storage)
→ br-storage (bridge for storage traffic)# Full setup
ip link add bond0 type bond mode active-backup miimon 100
ip link set eth0 master bond0
ip link set eth1 master bond0
ip link set bond0 up
ip link add link bond0 name bond0.10 type vlan id 10
ip link add link bond0 name bond0.20 type vlan id 20
ip link add br-mgmt type bridge
ip link set bond0.10 master br-mgmt
ip addr add 10.0.10.1/24 dev br-mgmt
ip link set br-mgmt up
ip link add br-prod type bridge
ip link set bond0.20 master br-prod
ip link set br-prod upPersistent Configuration with Netplan (Ubuntu)
# /etc/netplan/01-network.yaml
network:
version: 2
bonds:
bond0:
interfaces: [eth0, eth1]
parameters:
mode: active-backup
mii-monitor-interval: 100
vlans:
bond0.10:
id: 10
link: bond0
bond0.20:
id: 20
link: bond0
bridges:
br-mgmt:
interfaces: [bond0.10]
addresses: [10.0.10.1/24]
br-prod:
interfaces: [bond0.20]netplan apply