Operations 12 min read

Master Linux Network Configuration Across Distributions: netplan, nmcli, systemd‑networkd, and ifupdown

This step‑by‑step guide shows how to configure networking on Ubuntu/Debian with netplan, CentOS/RHEL with nmcli, Arch Linux with systemd‑networkd, and Alpine with ifupdown, plus common debugging commands and a systematic troubleshooting workflow.

AI Agent Super App
AI Agent Super App
AI Agent Super App
Master Linux Network Configuration Across Distributions: netplan, nmcli, systemd‑networkd, and ifupdown

1. Ubuntu/Debian: netplan (YAML)

Since Ubuntu 18.04, Canonical delegates network configuration to netplan, which translates YAML files into backend configurations for systemd‑networkd or NetworkManager. Configuration files reside in /etc/netplan/ and typically use names like 01-netcfg.yaml or 50-cloud-init.yaml.

Static IP example:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      dhcp4: no
      addresses: [192.168.1.100/24]
      routes:
        - to: default
          via: 192.168.1.1
      nameservers:
        addresses: [8.8.8.8, 1.1.1.1]

Key pitfalls: YAML is indentation‑sensitive (spaces only), dhcp4: no must be explicit, and the newer routes syntax replaces the deprecated gateway4. Test changes with sudo netplan try (auto‑rollback on failure) before applying with sudo netplan apply. For a quick DHCP setup, use a three‑line YAML with dhcp4: yes.

2. CentOS/RHEL: NetworkManager + nmcli

From CentOS 7 onward, NetworkManager is the primary manager. The nmcli CLI lets you configure networking without editing files directly.

Show current status:

$ nmcli device status
DEVICE  TYPE      STATE      CONNECTION
ens33   ethernet  connected  ens33
lo      loopback  unmanaged  --

Configure a static IP:

$ nmcli con mod ens33 ipv4.addresses 10.0.0.50/24
$ nmcli con mod ens33 ipv4.gateway 10.0.0.1
$ nmcli con mod ens33 ipv4.dns 8.8.8.8
$ nmcli con mod ens33 ipv4.method manual

Reload and activate the connection with nmcli con reload and nmcli con up ens33. Verify the settings using nmcli device show ens33 | grep IP. Configuration files live under /etc/NetworkManager/system-connections/, but direct file edits are rarely needed. CentOS 8/RHEL 8 also provide nmstate, a declarative tool similar to netplan, though nmcli remains the most reliable.

3. Arch Linux: systemd‑networkd

Arch follows the KISS principle; systemd‑networkd is the lightweight network manager within the systemd ecosystem.

Configuration files are placed in /etc/systemd/network/ with a .network suffix. Files are processed in lexical order, allowing numeric prefixes to control priority.

DHCP configuration:

[Match]
Name=enp0s3

[Network]
DHCP=yes

[DHCP]
RouteMetric=100

Static IP configuration:

[Match]
Name=enp0s3

[Network]
Address=192.168.1.100/24
Gateway=192.168.1.1
DNS=8.8.8.8
DNS=1.1.1.1

After editing, restart the service with sudo systemctl restart systemd-networkd and enable systemd-resolved for DNS handling: sudo systemctl enable --now systemd-resolved.

4. Alpine Linux: ifupdown

Alpine uses the classic ifupdown implementation from busybox. The main file is /etc/network/interfaces, mirroring Debian’s older style.

DHCP example:

auto eth0
iface eth0 inet dhcp

Static IP example:

auto eth0
iface eth0 inet static
  address 192.168.1.100
  netmask 255.255.255.0
  gateway 192.168.1.1

DNS servers are defined in /etc/resolv.conf (e.g., nameserver 8.8.8.8, nameserver 1.1.1.1). Apply changes with /etc/init.d/networking restart or by restarting the network service.

5. Common verification commands

After applying configurations, run the following to confirm connectivity:

ip addr – shows assigned IPs.

ip route – displays the routing table and default gateway.

ping – tests reachability of the gateway and external DNS.

ss – checks listening sockets (e.g., ss -tulpn | grep :80).

resolvectl – inspects DNS resolver status on systemd‑based systems.

6. Systematic troubleshooting flow

When connectivity fails, follow these steps (covers ~90% of cases):

Physical layer : ip link show; if the interface is DOWN, bring it up with ip link set eth0 up. Verify VM bridge settings if applicable.

IP configuration : ip addr; ensure an address is present. In DHCP mode, a missing address may indicate a dead DHCP server or MAC filtering.

Routing : ip route; confirm a default via … entry exists.

DNS : If IP ping works but hostnames do not, check /etc/resolv.conf or resolvectl status. Remember that some distros manage resolv.conf automatically.

Firewall : Temporarily disable iptables or firewalld to see if rules are blocking traffic. In production, adjust rules rather than leaving the firewall off.

SELinux (CentOS/RHEL) : Query status with getenforce. If Enforcing interferes, set permissive mode with setenforce 0 for testing, but apply proper policies for long‑term use.

Following this logical flow lets you quickly locate and fix most network issues across any Linux distribution.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Linuxtroubleshootingnetwork configurationnmclinetplanifupdownsystemd-networkd
AI Agent Super App
Written by

AI Agent Super App

AI agent applications, installation, large-model testing, computer fundamentals, IT operations and maintenance exchange, network technology exchange, Linux learning

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.