2.3.1. Network Interface Configuration (NetworkManager and Netplan)
💡 First Principle: Different distributions use different network management daemons, but they all ultimately write the same kernel data structures (routes, addresses, link state). Understanding which tool is in charge on your system is the first step to making any network change.
Which tool is in use?
| Tool | Typical Distro | Config Location |
|---|---|---|
| NetworkManager (nmcli) | RHEL, Fedora, Rocky, AlmaLinux, Ubuntu Desktop | /etc/NetworkManager/ |
| Netplan | Ubuntu Server 18.04+ | /etc/netplan/*.yaml |
| systemd-networkd | Minimal systems, containers | /etc/systemd/network/ |
NetworkManager — nmcli:
nmcli device status # List all network interfaces and state
nmcli connection show # List all configured connections
nmcli connection show "ens3" # Details for a specific connection
# Configure a static IP
nmcli connection modify "ens3" \
ipv4.addresses "192.168.1.100/24" \
ipv4.gateway "192.168.1.1" \
ipv4.dns "8.8.8.8,8.8.4.4" \
ipv4.method manual
nmcli connection up "ens3" # Apply changes
nmcli connection reload # Reload all connections
# Create a new connection
nmcli connection add type ethernet ifname ens4 con-name "office-net" \
ipv4.addresses "10.0.0.5/24" ipv4.method manual
Netplan (Ubuntu Server):
Netplan uses YAML configuration files in /etc/netplan/. Changes require netplan apply to take effect — Netplan generates backend configuration (usually for NetworkManager or systemd-networkd) from the YAML.
# /etc/netplan/00-installer-config.yaml
network:
version: 2
ethernets:
ens3:
dhcp4: false
addresses:
- 192.168.1.100/24
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 1.1.1.1]
netplan try # Apply temporarily (auto-reverts after 120s if not confirmed)
netplan apply # Apply permanently
netplan status # Show current network state
Network Configuration Files:
/etc/hosts # Static hostname-to-IP mappings (checked before DNS)
/etc/resolv.conf # DNS resolver configuration (nameserver, search domain)
/etc/nsswitch.conf # Name service switch: order of resolution (files, dns, myhostname)
The line hosts: files dns in /etc/nsswitch.conf means "check /etc/hosts first, then query DNS." This is why adding an entry to /etc/hosts overrides DNS for that hostname.
⚠️ Exam Trap: Changes made with ip address add or ip route add are runtime-only — they disappear on reboot. To persist changes, you must configure them through NetworkManager (nmcli), Netplan, or systemd-networkd. This is the same pattern as firewalld runtime vs. permanent rules.
Reflection Question: You add a static route with ip route add 10.0.0.0/8 via 192.168.1.1 and it works perfectly. After a scheduled reboot the next morning, the route is gone. What is the correct way to make this route persistent on a RHEL system?