3.3 Linux Network Configuration, nmcli, Netplan & Resolution

Key Takeaways

  • NetworkManager separates devices from saved connection profiles. Use nmcli to inspect, edit and activate the appropriate profile.

  • Netplan renders YAML through networkd or NetworkManager. Netplan try requests timed rollback if unconfirmed. Verify any rollback and keep a recovery console for remote work.

  • Name Service Switch order is host-specific. A successful files lookup precedes DNS on a host configured with hosts: files dns and ordinary status rules.

  • Use ip link, ip address and ip route to check the interface and selected path, then ss and an application-level probe to check service reachability.

Last updated: November 2026

Linux Network Configuration, nmcli, Netplan & Resolution

Configuring network interfaces, routing tables, and domain name resolution is a fundamental responsibility of any enterprise Linux administrator. Contemporary distributions have transitioned away from legacy, ad-hoc shell scripts toward declarative configuration frameworks and centralized network daemons. This chapter covers the essential technical requirements for Linux network configuration, using NetworkManager (nmcli), Netplan YAML declarations, the Name Service Switch resolution chain, and the modern iproute2 diagnostic toolset.


1. NetworkManager and nmcli

On a Linux system that uses NetworkManager, the daemon applies profiles to interfaces. The keyfile plugin commonly stores local persistent profiles in /etc/NetworkManager/system-connections/. It also reads vendor or runtime configuration and can coexist with other storage plugins.

Connections vs. Devices

A core conceptual distinction in NetworkManager is the difference between a Device and a Connection:

  • Device (Interface): The physical or virtual network hardware identified by the kernel (e.g., eth0, ens33, enp0s31f6, wlan0).
  • Connection (Profile): A collection of configuration settings (IP address, subnet mask, default gateway, DNS servers, MTU) applied to a device. Multiple profiles can describe alternatives for one interface, for example "Office-Static" and "Field-DHCP". Inspect which one is active rather than assuming a saved profile has been applied.

Command-Line Administration with nmcli

The nmcli utility inspects and changes NetworkManager state. This example assumes NetworkManager manages eth0, with an available static address and usable DNS resolvers on the lab network:

# Inspect hardware device status and associated connection profiles
nmcli device status
# DEVICE      TYPE      STATE      CONNECTION
# eth0        ethernet  connected  static-eth0
# lo          loopback  unmanaged  --

# Display all configured connection profiles
nmcli connection show

# Create a new static IPv4 connection profile
nmcli con add type ethernet con-name "static-eth0" ifname eth0 \
  ip4 192.168.1.100/24 gw4 192.168.1.1

# Modify connection to assign primary and secondary DNS nameservers
nmcli con mod "static-eth0" ipv4.dns "192.168.1.53 192.168.1.54"

# Configure DNS search domain
nmcli con mod "static-eth0" ipv4.dns-search "corp.internal"

# Make this profile eligible for automatic activation
nmcli con mod "static-eth0" connection.autoconnect yes

# Activate the connection profile on the interface
nmcli con up "static-eth0"

# Deactivate the profile
nmcli con down "static-eth0"

# Reload connection profiles modified manually on disk
nmcli con reload

Use nmtui for a terminal menu or nm-connection-editor for the graphical editor where installed. CompTIA’s outline also uses the label nmconnect; use the documented commands on a live system. After activation, compare nmcli connection show --active and ip address show dev eth0 with the intended profile.


2. Declarative Network Configuration with Netplan

On Ubuntu installations that use Netplan, local declarative definitions commonly live under /etc/netplan/. An image may use a cloud-init-generated file. Check which tool owns that file before editing it.

Netplan Architecture & Backend Renderers

Netplan does not directly configure network interfaces at the kernel level. Instead, it reads its YAML definitions and generates native configuration profiles for one of two backend renderers:

  1. networkd: Delegates to systemd-networkd, commonly used for Ubuntu server installations.
  2. NetworkManager: Delegates to NetworkManager, commonly used for Ubuntu desktop installations. Inspect the configured renderer on the host.

Netplan YAML Syntax Rules

YAML parsing is strictly sensitive to formatting:

  • Indentation: Indent YAML with spaces. Use a consistent level for sibling keys in the same mapping.
  • Mappings: Use a separating space before inline values, such as dhcp4: false. A key can also introduce a nested mapping on the following line.

Example: Static IP Configuration with Gateway Route & DNS

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: false
      addresses:
        - 192.168.1.150/24
      routes:
        - to: default
          via: 192.168.1.1
      nameservers:
        addresses:
          - 192.168.1.53
          - 192.168.1.54
        search:
          - corp.internal

Applying and Testing Netplan Changes

# Generate backend configuration without applying it
netplan generate

# Apply the candidate temporarily and confirm if it works
netplan try

# On a supported Netplan version, inspect live interfaces
netplan status

netplan try applies a candidate configuration and requests rollback if it remains unconfirmed, by default after 120 seconds. Netplan documents rollback issues, so keep an alternate console during a remote change and verify the actual interface, route and connectivity if the trial times out. Check the on-disk YAML before rebooting. If applying a prepared configuration directly is intentional, netplan apply does not provide the same confirmation timer.

Other distributions may use different tooling. When supporting an existing host, identify its active renderer and configuration owner before translating a permanent change.

3. Name Resolution & systemd-resolved

On a glibc system, applications that use the system’s Name Service Switch (NSS) consult the sources configured in the hosts: line in /etc/nsswitch.conf. For example:

hosts: files dns myhostname

With normal status actions, files checks /etc/hosts and returns a successful match. If it finds no match, dns consults the resolver, and the optional myhostname service can answer queries for the local hostname. Source ordering and actions can differ, and programs that query DNS directly bypass the NSS file lookup. To compare, use getent ahostsv4 db01.corp.internal for NSS and dig db01.corp.internal for DNS.

On a host whose /etc/resolv.conf points at the systemd-resolved stub, the DNS client may talk to 127.0.0.53, which forwards eligible queries to configured upstream servers. This is one supported mode. Inspect the actual file or symlink and the resolver status before changing anything.

Static Local Mappings: /etc/hosts

The /etc/hosts file provides local hostname mappings for clients configured to use it:

127.0.0.1   localhost localhost.localdomain
::1         localhost localhost.localdomain
192.168.1.50 db01.corp.internal db01

The Resolver Configuration: /etc/resolv.conf

A traditional /etc/resolv.conf can list nameservers and domain search suffixes, as in this lab example:

nameserver 192.168.1.53
nameserver 192.168.1.54
search corp.internal example.com
options timeout:2 attempts:3

Modern Resolution with systemd-resolved

Where systemd-resolved is active, it can cache and route lookups to per-link DNS servers. A common stub setup links /etc/resolv.conf to /run/systemd/resolve/stub-resolv.conf. Other modes exist. Use resolvectl to inspect or change the resolver state:

# Display resolution status, per-interface DNS servers, and DNSSEC state
resolvectl status

# Query DNS for a domain through systemd-resolved
resolvectl query db01.corp.internal

# Dynamically assign DNS nameservers to interface eth0
resolvectl dns eth0 192.168.1.53 192.168.1.54

# Assign a search domain to the runtime resolver settings for eth0
resolvectl domain eth0 corp.internal

# Flush the local DNS cache
resolvectl flush-caches

4. Essential Network Diagnostic Utilities

System administrators require a robust toolkit to troubleshoot routing, interface states, socket bindings, and DNS resolution.

The iproute2 Suite (Modern Replacement for net-tools)

The iproute2 suite provides commands for live link, address, route and neighbor state. On a host with older net-tools commands you may see the corresponding operations:

Legacy Command (net-tools)Modern Command (iproute2)Practical Operation Example
ifconfigip addr (ip a)ip addr show dev eth0 (displays IP, subnet, MAC, and flags)
ifconfig eth0 up/downip link set dev ...ip link set dev eth0 up (activates link state)
route -nip route (ip r)ip route show (displays kernel routing table)
route add default gw ...ip route add default via ...ip route add default via 192.168.1.1 dev eth0
route add -net ...ip route add <cidr> via ...ip route add 10.50.0.0/16 via 192.168.1.254 dev eth0
arp -anip neigh (ip n)ip neigh show (displays ARP / IPv6 neighbor cache)

Socket Statistics: ss

The ss command reports socket state. Select listening TCP and UDP endpoints as a first check when a service is unreachable:

# Inspect all listening TCP and UDP sockets with numeric port formatting
ss -tuln
# Netid State  Recv-Q Send-Q Local Address:Port  Peer Address:Port
# tcp   LISTEN 0      128          0.0.0.0:22         0.0.0.0:*
# tcp   LISTEN 0      511          0.0.0.0:80         0.0.0.0:*
# udp   UNCONN 0      0            0.0.0.0:53         0.0.0.0:*

# Display available process information; full details may require privileges
ss -tulpn
  • -t: Display TCP sockets.
  • -u: Display UDP sockets.
  • -l: Show only listening sockets (omit active outbound client connections).
  • -n: Numeric output (bypasses service and hostname resolution, preventing delays).
  • -p: Show process name and Process ID (PID) owning the socket.

HTTP endpoint inspection with curl

curl -I https://api.example.test requests HTTP headers using HEAD. The application can respond differently to GET, so use a regular GET for a health endpoint that only supports that method. Add -v to show connection and protocol details. A successful TCP connection alone does not verify the HTTP route or application status.

DNS Interrogation: dig and nslookup

  • dig (Domain Information Groper): The premier utility for querying DNS nameservers:
    # Query A records for a domain
    dig example.com
    
    # Query a named lab resolver for MX records in short format
    dig @192.168.1.53 example.com MX +short
    
    # Perform a reverse DNS lookup (query PTR record for IP)
    dig -x 192.168.1.100
    
  • nslookup: Interactive and batch DNS lookup tool available across Windows and Linux environments.

Connectivity and link checks

ToolWhat to check
hostnameThe current system hostname. Check DNS separately when remote clients cannot resolve it.
ethtool eth0Supported and negotiated speed, duplex and link state for a supported Ethernet interface.
ping or ping -6ICMP echo reachability for IPv4 or IPv6 as applicable. Some systems offer ping6 as a separate name. A blocked echo does not rule out application traffic.
traceroute and tracepathRouters that answer probes along a path. Tracepath also reports path MTU information. Silent hops can still forward traffic.
mtrRepeated path probes, useful for comparing latency and loss across responding hops.
ncA direct connection test for a specific service endpoint. Check its implementation before using flags.
iperf3Controlled throughput measurement using a client and a server under your control.
nmapInventory exposed services on systems you administer or are authorized to assess. Use ss to verify the local listeners as well.
tcpdumpInspect packets on a chosen interface where authorized. A capture can distinguish a request that leaves from a reply that never arrives.
Test Your Knowledge

On an Ubuntu host that uses Netplan, an administrator wants to test candidate network settings from a console. Which command applies the trial with a confirmation timer and requests rollback if not confirmed?

A

netplan apply

B

netplan try

C

netplan generate

D

netplan status

Test Your Knowledge

A Linux administrator needs to create a persistent NetworkManager profile named 'prod-lan' that assigns static IP 10.0.10.25/24 with default gateway 10.0.10.1 to interface eth0. Which command accomplishes this?

A

nmcli con add type ethernet con-name "prod-lan" ifname eth0 ip4 10.0.10.25/24 gw4 10.0.10.1

B

nmcli device set eth0 ip4 10.0.10.25/24 gateway 10.0.10.1 con-name "prod-lan"

C

ip addr add 10.0.10.25/24 dev eth0 && ip route add default via 10.0.10.1

D

nmtui --set-ip eth0 10.0.10.25/24 10.0.10.1 "prod-lan"

Test Your Knowledge

A glibc application performs an IPv4 lookup using the normal NSS resolver on a host configured with hosts: files dns myhostname and no custom NSS status actions. /etc/hosts has server01.corp.internal at 192.168.1.50, and DNS reports 10.0.0.50. Which address does this lookup return?

A

10.0.0.50, because DNS always overrides the hosts file

B

Neither address, because a conflict returns NXDOMAIN

C

192.168.1.50, because the successful files lookup returns first

D

An arbitrary address selected from both values

Sections you finish are checked off in the contents.