Red Hat System Administration I · RH124

Chapter 18

Managing Network Configuration

Connection profiles · Static routes · DNS details · Troubleshooting
CIS126RH — Mesa Community College
Create and manage multiple NetworkManager connection profiles, configure static routes and DNS in detail, and verify and troubleshoot network settings.

Key Commands

  • nmcli connection add
  • nmcli connection clone
  • ip route add
  • ss
  • tracepath

A device can have several saved profiles; only one is active at a time.

# Create a brand-new connection profile from scratch
nmcli connection add type ethernet con-name static-eth0 ifname eth0 \
  ipv4.method manual ipv4.addresses 192.168.1.50/24 ipv4.gateway 192.168.1.1

# Duplicate an existing profile as a starting point for a new one
nmcli connection clone eth0 eth0-backup

# Rename a connection profile
nmcli connection modify eth0-backup connection.id eth0-lab

# Delete a connection profile entirely
nmcli connection delete eth0-backup

# Control whether a profile activates automatically at boot
nmcli connection modify static-eth0 connection.autoconnect yes
Tip — Clone Before You ExperimentA clone of a working profile gives you a known-good configuration to return to.

NetworkManager stores each profile as a keyfile. Edit with nmcli or nmtui; knowing the location helps with auditing and backups.

# Connection profiles are stored here, one file per connection
ls /etc/NetworkManager/system-connections/

# View a profile's raw keyfile contents (readable only by root)
sudo cat /etc/NetworkManager/system-connections/static-eth0.nmconnection
Warning — Reload After Manual EditsNetworkManager doesn't notice hand edits on its own. Run nmcli connection reload, then reactivate the connection.
# View the current routing table
ip route show

# Add a temporary static route (lost on reboot / interface restart)
sudo ip route add 10.10.20.0/24 via 192.168.1.254

# Remove a route
sudo ip route del 10.10.20.0/24

# Add a PERSISTENT static route to a connection profile
nmcli connection modify eth0 +ipv4.routes "10.10.20.0/24 192.168.1.254"

# Reactivate the connection to apply it
nmcli connection up eth0
Note — Two Different Kinds of "Temporary"ip route changes the running system now but saves nothing. nmcli saves the change but applies it only when the connection is reactivated.
# Set one or more DNS servers on a connection
nmcli connection modify eth0 ipv4.dns "192.168.1.1 8.8.8.8"

# Set a DNS search domain, so short names get it appended automatically
nmcli connection modify eth0 ipv4.dns-search example.com

# Prevent DHCP-provided DNS servers from being used, keeping only the ones set above
nmcli connection modify eth0 ipv4.ignore-auto-dns yes

# Apply the changes
nmcli connection up eth0

# Confirm what's actually in effect right now
cat /etc/resolv.conf
Tip — resolv.conf Is Generated, Not EditedNetworkManager rewrites /etc/resolv.conf from connection profiles. Make DNS changes with nmcli.

One connection can hold several IPv4 addresses, so one interface can answer on more than one address.

# Add a secondary address without replacing the primary one
nmcli connection modify eth0 +ipv4.addresses 192.168.1.51/24

# Remove a specific secondary address
nmcli connection modify eth0 -ipv4.addresses 192.168.1.51/24

# Apply the change
nmcli connection up eth0
Exam NoteFor multi-value properties, + adds an item and - removes one. With neither, the value replaces the whole list.
# Overall connectivity status summary
nmcli general status

# Full detail on one device: state, IP config, DNS, routes
nmcli device show eth0

# Show listening TCP and UDP sockets, with numeric ports
ss -tuln

# Trace the network path to a destination, hop by hop
tracepath example.com

# Watch DNS resolution specifically
getent hosts example.com
Tip — nmcli device show Is the One-Stop SummaryOne command shows a device's full effective configuration.
keyfile
File storing a NetworkManager profile in /etc/NetworkManager/system-connections/
static route
A manually configured route for a specific network through a specific router
search domain
Domain automatically appended to short host names during lookup
secondary address
An additional IP address on the same connection
ss
Shows network sockets, such as listening ports
tracepath
Shows the path packets take to a destination, hop by hop
  1. Why clone a working connection profile before experimenting?
  2. Where are connection profiles stored, and what should you run after editing one by hand?
  3. What is the difference between ip route add and adding a route with nmcli?
  4. Why is hand-editing /etc/resolv.conf unreliable on a NetworkManager system?
  5. What do the + and - prefixes do in nmcli connection modify?
  6. What command shows the full configuration of eth0?
  7. What command traces the network path to a remote host?