22. Network Configuration
While commands like ip addr add manipulate networking state in memory, those changes are lost upon reboot. To establish persistent, production-grade networking, modern Linux distributions rely on management daemons—primarily NetworkManager.
22.1 NetworkManager & nmcli Fundamentals
Section titled “22.1 NetworkManager & nmcli Fundamentals”NetworkManager runs as a system service (NetworkManager.service) and manages both physical and virtual network interfaces. It separates physical Devices (hardware ports) from logical Connections (configuration profiles).
Service Control
Section titled “Service Control”# Verify NetworkManager service statesudo systemctl status NetworkManager
# Enable and start NetworkManagersudo systemctl enable --now NetworkManager
# Toggle entire networking subsystem on or offnmcli networking offnmcli networking onInspecting Devices and Connections
Section titled “Inspecting Devices and Connections”# View status of physical and virtual network hardwarenmcli device status
# Connect or disconnect a physical interfacesudo nmcli device connect eth0sudo nmcli device disconnect eth0
# List all configured connection profilesnmcli connection show
# View detailed properties of a specific profilenmcli connection show "office-eth0"22.2 Configuring Network Profiles with nmcli
Section titled “22.2 Configuring Network Profiles with nmcli”Production servers require predictable network configuration—either explicitly assigned Static IPs or centrally administered DHCP reservations.
1. Adding a Static IP Connection
Section titled “1. Adding a Static IP Connection”Create a persistent profile with an IP address, subnet mask, default gateway, and DNS servers:
sudo nmcli connection add type ethernet \ con-name static-eth0 \ ifname eth0 \ ipv4.method manual \ ipv4.addresses 192.168.2.20/24 \ ipv4.gateway 192.168.2.1 \ ipv4.dns "8.8.8.8 1.1.1.1" \ autoconnect yes2. Adding a DHCP Connection
Section titled “2. Adding a DHCP Connection”Configure an interface to automatically lease networking parameters:
sudo nmcli connection add type ethernet \ con-name dhcp-eth1 \ ifname eth1 \ ipv4.method auto \ autoconnect yes3. Modifying Existing Connections
Section titled “3. Modifying Existing Connections”Update properties on an active profile without recreating it:
# Change IP addresssudo nmcli connection modify static-eth0 ipv4.addresses 192.168.2.30/24
# Update default gatewaysudo nmcli connection modify static-eth0 ipv4.gateway 192.168.2.1
# Update DNS serverssudo nmcli connection modify static-eth0 ipv4.dns "8.8.4.4 1.0.0.1"4. Activating, Deactivating, and Deleting Connections
Section titled “4. Activating, Deactivating, and Deleting Connections”# Activate a connection profilesudo nmcli connection up static-eth0
# Deactivate a connection profilesudo nmcli connection down static-eth0
# Delete a profile permanentlysudo nmcli connection delete static-eth022.3 NIC Teaming & Bonding
Section titled “22.3 NIC Teaming & Bonding”In enterprise environments, a single network cable or NIC represents a single point of failure. NIC Teaming (and the kernel-level Bonding) aggregates multiple physical interfaces into a single logical link.
Objectives and Benefits
Section titled “Objectives and Benefits”- Increased Bandwidth: Aggregates individual link throughput for data-heavy workloads.
- Fault Tolerance & Redundancy: If one NIC or switch port fails, standby interfaces automatically sustain connectivity without downtime.
- Load Balancing: Distributes outbound and inbound traffic across member ports.
Teaming vs Bonding Comparison
Section titled “Teaming vs Bonding Comparison”| Feature | Kernel Bonding | NIC Teaming (teamd) |
||||
| Architecture | Kernel-space module | User-space daemon (teamd) |
| Modularity & Logic | Monolithic kernel drivers | Modular runner plugins |
| Configuration Format | Kernel module options | JSON-based configuration |
| Performance Overhead | Very low | Slightly higher (context switches) |
| Distribution Status | Universally supported | RHEL 7/8, SUSE (Deprecated in RHEL 9 in favor of bonding) |
22.4 Teaming Runner Modes
Section titled “22.4 Teaming Runner Modes”The operational behavior of a team is governed by its Runner:
| Runner Mode | Description | Switch Requirement | Common Use Case |
|||||
| activebackup | One port active; others stay on standby for instant failover | Standard unmanaged switch | High availability without switch config |
| loadbalance | Distributes traffic across ports using BPF hash algorithms | Standard unmanaged switch | Increased throughput |
| roundrobin | Transmits packets sequentially across all ports | Standard unmanaged switch | Maximum bandwidth (can cause out-of-order packets) |
| broadcast | Transmits all traffic across every port concurrently | Standard unmanaged switch | Ultra-reliable telemetry (rarely used) |
| lacp (802.3ad) | Dynamic link aggregation protocol | Requires managed switch configured with LACP | Enterprise datacenters & SANs |
22.5 Configuring NIC Teaming via nmcli
Section titled “22.5 Configuring NIC Teaming via nmcli”Step 1: Install teamd
Section titled “Step 1: Install teamd”- RHEL / AlmaLinux / Rocky:
Terminal window sudo dnf install teamd -y - Debian / Ubuntu:
Terminal window sudo apt install teamd -y
Step 2: Create the Team Master Interface
Section titled “Step 2: Create the Team Master Interface”Create the virtual master device team0 with the activebackup runner:
sudo nmcli connection add type team \ con-name team0 \ ifname team0 \ team.runner activebackup(For load balancing, use team.runner loadbalance)
Step 3: Add Slave Member Ports
Section titled “Step 3: Add Slave Member Ports”Attach physical interfaces (eth1 and eth2) to the team:
sudo nmcli connection add type team-slave \ con-name team0-port1 \ ifname eth1 \ master team0
sudo nmcli connection add type team-slave \ con-name team0-port2 \ ifname eth2 \ master team0Step 4: Configure Team IP Address & Activate
Section titled “Step 4: Configure Team IP Address & Activate”# Assign static IP to team0sudo nmcli connection modify team0 \ ipv4.method manual \ ipv4.addresses 192.168.1.100/24 \ ipv4.gateway 192.168.1.1 \ ipv4.dns "1.1.1.1"
# Activate the team and port connectionssudo nmcli connection up team0sudo nmcli connection up team0-port1sudo nmcli connection up team0-port2Step 5: Verify Team State with teamdctl
Section titled “Step 5: Verify Team State with teamdctl”Inspect real-time port states and active runners:
sudo teamdctl team0 stateOptional: Manual JSON Configuration (/etc/teamd/team0.conf)
Section titled “Optional: Manual JSON Configuration (/etc/teamd/team0.conf)”Alternatively, teamd can be configured directly with JSON:
{ "runner": { "name": "activebackup" }, "ports": { "eth1": {}, "eth2": {} }}Run teamd as a daemon:
sudo teamd -g -f /etc/teamd/team0.conf -d22.6 Software Bridging & VLANs
Section titled “22.6 Software Bridging & VLANs”1. Software Bridging (Layer 2 Switching)
Section titled “1. Software Bridging (Layer 2 Switching)”A network bridge behaves like a virtual Ethernet switch inside the Linux kernel. It allows multiple interfaces or virtual machines to share the same physical network segment.
# Create bridge interfacesudo nmcli connection add type bridge con-name br0 ifname br0
# Attach physical interface to bridgesudo nmcli connection add type bridge-slave con-name br0-slave ifname eth0 master br0
# Bring bridge upsudo nmcli connection up br0Crucial in hypervisors and container engines (e.g., Docker creates docker0 as a default bridge).
2. VLAN Tagging (802.1Q)
Section titled “2. VLAN Tagging (802.1Q)”VLANs logically isolate traffic on a single physical link by tagging packets with an integer ID (1 - 4094).
# Create VLAN 10 interface on physical device eth0sudo nmcli connection add type vlan \ con-name vlan10 \ ifname eth0.10 \ dev eth0 \ id 10 \ ipv4.method manual \ ipv4.addresses 10.10.10.50/24
# Activate VLANsudo nmcli connection up vlan10