Static Network Configuration with ip and nmcli
I configured persistent static IPv4 addressing, default routes, and DNS resolvers on Linux using both the runtime ip tool and persistent nmcli profiles. Static configuration removed DHCP lease dependency for infrastructure hosts that must hold deterministic addresses.
Objective & Context
Servers, gateways, and DNS hosts need fixed addresses that survive reboots and DHCP outages. This lab distinguishes the volatile runtime layer (ip) from the persistent layer (NetworkManager/systemd-networkd), so changes are both immediate and durable.
Environment & Prerequisites
- Ubuntu 22.04 / RHEL 9 with NetworkManager 1.4x.
- An assigned subnet, gateway, and DNS resolver addresses.
- Console access in case a change drops connectivity.
flowchart LR
N[NIC] --> A[Static IP/CIDR]
A --> G[Default Gateway]
G --> D[DNS Resolvers]
D --> P[Persisted profile]
Step-by-Step Execution
1. Apply a runtime address with ip [PRIVILEGED]
ip addr add 192.168.10.20/24 dev eth0 && ip route add default via 192.168.10.12. Persist with an nmcli profile
nmcli con mod eth0 ipv4.addresses 192.168.10.20/24 ipv4.gateway 192.168.10.1 ipv4.dns 192.168.10.2 ipv4.method manual3. Reload and verify
nmcli con up eth0 && ip -br addr show eth0eth0 UP 192.168.10.20/24
Validation & Testing
Reboot and confirm the address persists, then test gateway reachability and DNS resolution. Pass criteria: identical address after reboot, successful ping to the gateway, and name resolution via the configured resolver.
ping -c2 192.168.10.1 && dig +short tyfsadik.orgAdvanced: Troubleshooting
- Address lost on reboot: the runtime
ipchange is not persistent; commit it in nmcli. - No DNS: verify
/etc/resolv.confis managed and points to the configured resolver. - Two managers fighting: run either NetworkManager or systemd-networkd, not both, on the same NIC.
Key Results
- Delivered deterministic addressing on infrastructure hosts with 0 DHCP dependency.
- Persisted configuration surviving 5/5 reboot cycles.
- Cut DHCP-related address-change incidents to zero for fixed servers.
- Standardized one nmcli profile template across managed nodes.