A server that can’t reach the network after a reboot is effectively useless — you can’t SSH into it, it can’t serve web traffic, and it can’t reach package repositories to update itself. Configuring networking to come up automatically and correctly at boot time is therefore one of the most fundamental Linux administration skills. This article explains, from first principles, the different systems Linux distributions use to configure networking at boot — legacy /etc/network/interfaces, NetworkManager, and modern Netplan — with practical, real-world examples for each.
Why Boot-Time Network Configuration Matters
flowchart TD
A[System Boots] --> B[Kernel Detects Network Interfaces]
B --> C[Network Configuration Service Starts]
C --> D{Static or DHCP?}
D -->|Static| E[Apply Fixed IP/Gateway/DNS]
D -->|DHCP| F[Request IP from DHCP Server]
E --> G[Interface Up, Network Ready]
F --> GWithout correct boot-time configuration, a server might come up with no IP address at all, the wrong IP address, or no default route — any of which can mean losing remote access entirely, requiring physical console intervention to fix.
Two Approaches: DHCP vs. Static IP
| Approach | How It Works | Best For |
|---|---|---|
| DHCP | Interface automatically requests an IP from a DHCP server on the network | Most client machines, dynamic environments |
| Static IP | IP address, gateway, and DNS are manually and permanently configured | Servers, infrastructure that needs a fixed, predictable address |
Servers almost always use static IP addresses (or DHCP reservations tied to a MAC address), since services, DNS records, and firewall rules typically depend on a predictable address.
Method 1: Legacy Debian/Ubuntu — /etc/network/interfaces
Older Debian-based systems (and Ubuntu Server before 17.10) configure networking through this file.
Static IP Configuration Example
auto eth0
iface eth0 inet static
address 192.168.1.50
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 1.1.1.1
DHCP Configuration Example
auto eth0
iface eth0 inet dhcp
Apply changes:
sudo systemctl restart networking
Or bring an individual interface up/down:
sudo ifdown eth0 && sudo ifup eth0
Method 2: Modern Ubuntu — Netplan
Since Ubuntu 17.10+, Netplan is the default networking configuration system, using YAML files under /etc/netplan/.
Static IP Configuration Example
# /etc/netplan/01-netcfg.yaml
network:
version: 2
ethernets:
eth0:
dhcp4: no
addresses:
- 192.168.1.50/24
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 1.1.1.1]
DHCP Configuration Example
network:
version: 2
ethernets:
eth0:
dhcp4: yes
Applying Netplan Changes
sudo netplan applyTesting Before Committing (Safety Net)
Netplan supports a “try” mode that automatically reverts changes if you don’t confirm within a timeout — extremely useful when configuring networking remotely, since a bad config could otherwise lock you out entirely:
sudo netplan tryIf the new configuration breaks connectivity, it automatically rolls back after ~120 seconds unless you press Enter to confirm it works.
Method 3: RHEL/CentOS/Fedora — NetworkManager (nmcli)
RHEL-family distributions primarily use NetworkManager, controllable via the nmcli command-line tool.
Viewing Current Connections
nmcli connection showConfiguring a Static IP
sudo nmcli connection modify eth0 ipv4.addresses 192.168.1.50/24
sudo nmcli connection modify eth0 ipv4.gateway 192.168.1.1
sudo nmcli connection modify eth0 ipv4.dns "8.8.8.8 1.1.1.1"
sudo nmcli connection modify eth0 ipv4.method manual
sudo nmcli connection up eth0Configuring DHCP
sudo nmcli connection modify eth0 ipv4.method auto
sudo nmcli connection up eth0Legacy Equivalent: ifcfg Files
Older RHEL/CentOS systems (before NetworkManager became fully dominant) used files under /etc/sysconfig/network-scripts/:
# /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.1.50
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
ONBOOT=yes
ONBOOT=yes is the critical setting ensuring the interface activates automatically at boot.
Comparison Table: Boot-Time Network Configuration Systems
| System | Distros | Config Format | Config Location |
|---|---|---|---|
/etc/network/interfaces | Older Debian/Ubuntu | Plain text, iface blocks | /etc/network/interfaces |
| Netplan | Modern Ubuntu (17.10+) | YAML | /etc/netplan/*.yaml |
NetworkManager (nmcli) | RHEL/CentOS/Fedora, many desktops | Connection profiles (INI-like) | /etc/NetworkManager/system-connections/ |
ifcfg scripts (legacy) | Older RHEL/CentOS | Shell-variable style | /etc/sysconfig/network-scripts/ |
A Practical Walkthrough: Setting a Static IP on a New Ubuntu Server
Step 1: Identify your interface name
ip link showStep 2: Create/edit the Netplan config
sudo nano /etc/netplan/00-installer-config.yamlnetwork:
version: 2
ethernets:
ens160:
dhcp4: no
addresses:
- 10.0.0.20/24
routes:
- to: default
via: 10.0.0.1
nameservers:
addresses: [10.0.0.1, 1.1.1.1]
Step 3: Test safely before committing (especially over a remote SSH session)
sudo netplan tryStep 4: Apply permanently once confirmed working
sudo netplan applyStep 5: Verify
ip addr show ens160
ip route showEnsuring the Interface Comes Up at Boot (Not Just Now)
A very common mistake: an admin manually brings an interface up with ip addr add or ifconfig, tests it, and moves on — not realizing that command doesn’t persist across a reboot. Always confirm the setting lives in a persistent configuration file (Netplan YAML, nmcli connection profile, or /etc/network/interfaces), not just applied as a one-off runtime command.
# THIS DOES NOT PERSIST ACROSS REBOOT:
sudo ip addr add 192.168.1.50/24 dev eth0
# THIS DOES PERSIST (via Netplan, NetworkManager, etc. as shown above)
Real-World Use Case: Bonded/Redundant Network Interfaces
For servers needing network redundancy, multiple physical interfaces can be “bonded” into one logical interface configured at boot:
network:
version: 2
ethernets:
eth0: {}
eth1: {}
bonds:
bond0:
interfaces: [eth0, eth1]
addresses: [192.168.1.50/24]
parameters:
mode: active-backup
routes:
- to: default
via: 192.168.1.1
Best Practices
- Always test remote network changes with a safety net (
netplan try, or a scheduledatjob that reverts the change if you lose connectivity) to avoid locking yourself out. - Use static IPs (or DHCP reservations) for servers, never plain DHCP without reservation, to keep DNS records and firewall rules accurate.
- Document your IP addressing scheme for the whole network, avoiding accidental conflicts.
- Keep a backup of working network configs before making changes, so you can quickly restore if something goes wrong.
- Verify DNS as well as IP connectivity after any change — a host can have a valid IP but broken DNS resolution.
- Use out-of-band access (IPMI, cloud console, physical KVM) as a fallback whenever making risky network changes remotely.
Troubleshooting
Problem: Interface has no IP address after boot
Check whether the interface is set to start automatically:
ip link show
cat /etc/netplan/*.yaml # Ubuntu
nmcli connection show # RHEL/FedoraProblem: netplan apply returns an error
Check YAML syntax carefully — indentation errors are the most common cause:
sudo netplan --debug applyProblem: Static IP configured but no internet access
Check the default route and DNS separately — a missing gateway or DNS entry can each independently break connectivity:
ip route show
cat /etc/resolv.confProblem: Lost SSH access after a network config change
If you used netplan try, it will auto-revert after ~120 seconds. If not, you’ll need out-of-band console access to fix the configuration directly.
Problem: NetworkManager and Netplan conflict on Ubuntu Desktop
Some Ubuntu desktop installations run NetworkManager as the actual backend for Netplan. Check which renderer Netplan is using:
network:
version: 2
renderer: NetworkManager # or 'networkd'
Conclusion
Boot-time network configuration is the foundation that everything else — SSH access, web services, monitoring — depends on. Whether you’re working with legacy /etc/network/interfaces, modern Netplan YAML on Ubuntu, or NetworkManager’s nmcli on RHEL-family systems, the underlying goal is the same: ensure the correct IP configuration is applied automatically and reliably every time the system boots, without requiring manual intervention. Testing changes safely (especially over remote connections) and keeping configurations well-documented will save you from one of the most common and painful sysadmin mistakes: getting locked out of your own server.
