CIS126RH | RHEL System Administration 1
Mesa Community College
Create, modify, and manage network connections using the command line
Configure IPv4 and IPv6 addresses, gateways, and DNS servers
Configure system hostname and understand hostname types
Know where network settings are stored and how to edit them
NetworkManager is a daemon that manages network connections dynamically. It uses connection profiles that define network settings and can be activated on network devices.
Command-line interface for scripting and server administration
Text-based UI for interactive configuration
Graphical interface (desktop systems)
Stored in /etc/NetworkManager/
# List connections (profiles)
[student@server ~]$ nmcli connection show
NAME UUID TYPE DEVICE
ens33 a1b2c3d4-e5f6-7890-abcd-ef1234567890 ethernet ens33
Home b2c3d4e5-f6a7-8901-bcde-f23456789012 wifi --
# List devices (interfaces)
[student@server ~]$ nmcli device status
DEVICE TYPE STATE CONNECTION
ens33 ethernet connected ens33
lo loopback unmanaged --
nmcli [OPTIONS] OBJECT { COMMAND | help }
# Primary objects:
nmcli general # NetworkManager status and logging
nmcli networking # Overall networking on/off
nmcli connection # Manage connections (short: con)
nmcli device # Manage devices (short: dev)
| Object | Key Commands | Purpose |
|---|---|---|
connection | show, add, modify, up, down, delete, reload | Manage profiles |
device | status, show, connect, disconnect, reapply | Manage interfaces |
general | status, hostname, logging | NM status + logs |
networking | on, off, connectivity | Master on/off switch |
nmcli con mod ens33 and nmcli connection modify ens33 are identical.
# Show all settings for a connection
[student@server ~]$ nmcli connection show ens33
connection.id: ens33
connection.uuid: a1b2c3d4-e5f6-7890-abcd-ef1234567890
connection.type: 802-3-ethernet
connection.interface-name: ens33
connection.autoconnect: yes
ipv4.method: auto
ipv4.addresses: --
ipv4.gateway: --
ipv4.dns: --
# Get a single field value (good for scripting)
[student@server ~]$ nmcli -g ipv4.addresses connection show ens33
192.168.1.100/24
# Show all IPv4 settings for a connection
[student@server ~]$ nmcli -f ipv4 connection show ens33
# Compare configured profile vs. active runtime values
[student@server ~]$ nmcli connection show ens33 | grep ipv4
# Show runtime device settings (what is actually in use)
[student@server ~]$ nmcli device show ens33 | grep IP4
connection show reads the profile file. device show reads the live, active settings. After modifying a profile without reactivating, these may differ.
# Create a new DHCP connection profile
[root@server ~]# nmcli connection add con-name "Office-DHCP" type ethernet ifname ens33
# The profile appears in the list (not yet active)
[student@server ~]$ nmcli connection show
NAME UUID TYPE DEVICE
Office-DHCP c3d4e5f6-a7b8-9012-cdef-345678901234 ethernet --
ens33 a1b2c3d4-e5f6-7890-abcd-ef1234567890 ethernet ens33
# Activate the new connection
[root@server ~]# nmcli connection up Office-DHCP
Connection successfully activated
# Verify active connection
[student@server ~]$ nmcli device status
DEVICE TYPE STATE CONNECTION
ens33 ethernet connected Office-DHCP
# Create connection with static IPv4
[root@server ~]# nmcli connection add con-name "Server-Static" type ethernet ifname ens33 ipv4.method manual ipv4.addresses 192.168.1.50/24 ipv4.gateway 192.168.1.1 ipv4.dns "8.8.8.8,8.8.4.4"
# Activate the static connection
[root@server ~]# nmcli connection up Server-Static
nmcli connection up <name> to activate it. Unactivated profiles do not take effect.
# Change an existing connection from DHCP to static
[root@server ~]# nmcli connection modify ens33 ipv4.method manual ipv4.addresses 192.168.1.100/24 ipv4.gateway 192.168.1.1 ipv4.dns "8.8.8.8"
# Add an additional DNS server (+ prefix appends)
[root@server ~]# nmcli connection modify ens33 +ipv4.dns "8.8.4.4"
# Remove a DNS server (- prefix removes)
[root@server ~]# nmcli connection modify ens33 -ipv4.dns "8.8.4.4"
# Add a second IP address
[root@server ~]# nmcli connection modify ens33 +ipv4.addresses 192.168.1.101/24
# Disable autoconnect (prevent auto-start at boot)
[root@server ~]# nmcli connection modify ens33 connection.autoconnect no
# Changes saved but not active until explicitly applied
[root@server ~]# nmcli connection up ens33 # Reactivate connection
[root@server ~]# nmcli connection reload # Reload all profiles from disk
# Reapply without full reconnect (keeps existing sessions)
[root@server ~]# nmcli device reapply ens33
Full reconnect — drops and re-establishes. Some settings require this.
Applies changes without dropping the connection — less disruptive for some changes.
# Create a static IPv6 connection
[root@server ~]# nmcli connection add con-name "IPv6-Static" type ethernet ifname ens33 ipv6.method manual ipv6.addresses "2001:db8::10/64" ipv6.gateway "2001:db8::1"
# Add IPv6 to an existing connection (dual-stack)
[root@server ~]# nmcli connection modify ens33 ipv6.method manual ipv6.addresses "2001:db8::100/64" ipv6.gateway "2001:db8::1"
# Disable IPv6 on a connection
[root@server ~]# nmcli connection modify ens33 ipv6.method disabled
# Enable IPv6 SLAAC (stateless auto-configuration)
[root@server ~]# nmcli connection modify ens33 ipv6.method auto
# IPv6 link-local only (no global address assigned)
[root@server ~]# nmcli connection modify ens33 ipv6.method link-local
# Set DNS servers for a connection
[root@server ~]# nmcli connection modify ens33 ipv4.dns "8.8.8.8 8.8.4.4"
# Set DNS search domains
[root@server ~]# nmcli connection modify ens33 ipv4.dns-search "example.com lab.local"
# Prevent DHCP from overwriting DNS settings
[root@server ~]# nmcli connection modify ens33 ipv4.ignore-auto-dns yes
# View the generated resolver configuration
[student@server ~]$ cat /etc/resolv.conf
# Generated by NetworkManager
search example.com lab.local
nameserver 8.8.8.8
nameserver 8.8.4.4
# Check which connection provides DNS for a device
[student@server ~]$ nmcli device show ens33 | grep DNS
nmcli connection modify.
# Activate a connection
[root@server ~]# nmcli connection up ens33
# Activate on a specific device
[root@server ~]# nmcli connection up ens33 ifname ens33
# Deactivate a connection
[root@server ~]# nmcli connection down ens33
# Disconnect a device (deactivates its current connection)
[root@server ~]# nmcli device disconnect ens33
# Reconnect a device (activates its default connection)
[root@server ~]# nmcli device connect ens33
# Reload connection profiles from disk (after manual file edits)
[root@server ~]# nmcli connection reload
# Reapply settings to device without full reconnect
[root@server ~]# nmcli device reapply ens33
# Delete a connection profile (permanent)
[root@server ~]# nmcli connection delete "Old-Connection"
nmcli con shownmtui (NetworkManager Text User Interface) provides a menu-driven interface for network configuration — useful when you don't remember exact nmcli syntax.
# Launch nmtui
[root@server ~]# nmtui
Create, modify, or delete connection profiles
Turn connections on or off interactively
Change the system hostname from a menu
Tab, arrows, Enter, Esc to navigate menus
# View current hostname
[student@server ~]$ hostname
server.example.com
# View all hostname types and system info
[student@server ~]$ hostnamectl
Static hostname: server.example.com
Icon name: computer-vm
Chassis: vm
Machine ID: a1b2c3d4...
Boot ID: e5f6a7b8...
Virtualization: vmware
Operating System: Red Hat Enterprise Linux 9.0
CPE OS Name: cpe:/o:redhat:enterprise_linux:9::baseos
Kernel: Linux 5.14.0-70.el9.x86_64
Architecture: x86-64
# Set hostname persistently (writes to /etc/hostname)
[root@server ~]# hostnamectl set-hostname server.example.com
# Set pretty hostname (human-friendly display name)
[root@server ~]# hostnamectl set-hostname "Web Server 01" --pretty
# Update /etc/hosts for local resolution
[root@server ~]# echo "192.168.1.100 server.example.com server" >> /etc/hosts
# Verify the change
[student@server ~]$ hostnamectl
[student@server ~]$ hostname -f # Show FQDN
server.example.com. After setting the hostname, update /etc/hosts so the FQDN resolves locally without DNS.
# View a connection profile file (RHEL 9 keyfile format)
[root@server ~]# cat /etc/NetworkManager/system-connections/ens33.nmconnection
[connection]
id=ens33
type=ethernet
interface-name=ens33
[ipv4]
method=manual
address1=192.168.1.100/24,192.168.1.1
dns=8.8.8.8;
| File / Directory | Purpose |
|---|---|
/etc/NetworkManager/system-connections/ | Connection profile files (.nmconnection) |
/etc/NetworkManager/NetworkManager.conf | Main NM daemon configuration |
/etc/hostname | System static hostname |
/etc/hosts | Static name-to-IP mappings |
/etc/resolv.conf | DNS resolver (NM-managed, do not edit) |
[connection] — Profile name, type, interface
[ethernet] — Ethernet-specific (MAC, MTU)
[ipv4] — IPv4 method, addresses, DNS
[ipv6] — IPv6 configuration
192.168.1.100/24,192.168.1.1. DNS servers end with semicolons. After editing, run nmcli connection reload.
# Verify interface address and state
[student@server ~]$ ip addr show ens33
[student@server ~]$ nmcli device show ens33
# Verify routing table
[student@server ~]$ ip route
[student@server ~]$ ip route get 8.8.8.8
# Verify DNS configuration
[student@server ~]$ cat /etc/resolv.conf
[student@server ~]$ dig google.com
# Test connectivity layer by layer
[student@server ~]$ ping -c 3 192.168.1.1 # Gateway
[student@server ~]$ ping -c 3 8.8.8.8 # Internet IP
[student@server ~]$ ping -c 3 google.com # DNS resolution
# Check NetworkManager logs
[student@server ~]$ journalctl -u NetworkManager --since "5 minutes ago"
# Task: Change server from DHCP to static IP
[root@server ~]# nmcli con mod ens33 ipv4.method manual ipv4.addresses 192.168.1.100/24 ipv4.gateway 192.168.1.1 ipv4.dns "8.8.8.8 8.8.4.4"
[root@server ~]# nmcli con up ens33
# Task: Add a second IP address
[root@server ~]# nmcli con mod ens33 +ipv4.addresses 192.168.1.101/24
[root@server ~]# nmcli con up ens33
# Task: Disable IPv6
[root@server ~]# nmcli con mod ens33 ipv6.method disabled
[root@server ~]# nmcli con up ens33
# Task: Use custom DNS, ignore DHCP-provided DNS
[root@server ~]# nmcli con mod ens33 ipv4.dns "10.0.0.53" ipv4.ignore-auto-dns yes
[root@server ~]# nmcli con up ens33
# Problem: Connection won't activate
[root@server ~]# journalctl -u NetworkManager -n 50
[root@server ~]# nmcli connection show "con-name" # Check for config errors
# Problem: IP address not assigned
[student@server ~]$ nmcli device status # Is device connected?
[student@server ~]$ ip link show ens33 # Is link UP?
# Problem: Can't reach gateway (check address and route)
[student@server ~]$ ip route # Default route present?
[student@server ~]$ ip addr # Correct address/prefix?
# Problem: Reach IP but not hostnames (DNS)
[student@server ~]$ cat /etc/resolv.conf # Nameserver configured?
[student@server ~]$ dig @8.8.8.8 google.com # Bypass local DNS
# Problem: Changes not taking effect
[root@server ~]# nmcli connection reload
[root@server ~]# nmcli connection up ens33
nmcli con up after every modifyip addr and ping/etc/resolv.conf directlynmcli: Primary tool — connection add/modify/up/down/delete. Changes persist. Always activate with con up after modifying.
Static IP: Set ipv4.method manual, specify ipv4.addresses (CIDR), ipv4.gateway, and ipv4.dns. Reactivate to apply.
Hostname: Use hostnamectl set-hostname <FQDN>. Update /etc/hosts for local resolution.
Files: Profiles in /etc/NetworkManager/system-connections/. Run nmcli con reload after manual edits.
nmcli device status+ prefix syntax/etc/hosts/etc/NetworkManager/system-connections/