Network configuration on RHEL 9 is managed by NetworkManager, and the primary tools for working with it are nmcli (NetworkManager Command-Line Interface) and the traditional ip command from the iproute2 package. Understanding both is essential: nmcli creates persistent network profiles that survive reboots and are managed by NetworkManager, while the ip command makes temporary changes ideal for testing and troubleshooting that are not written to disk. This guide covers configuring static IP addresses, default gateways, and DNS servers; adding secondary IP addresses; creating bonded and bridged interfaces; viewing routing tables; and testing connectivity. Whether you are provisioning a new server, changing an IP address after a data centre move, or debugging a routing problem, these tools are your network control plane.

Prerequisites

  • RHEL 9 server with root or sudo access
  • NetworkManager running (default on RHEL 9)

Step 1 — View Current Network Configuration

# Show all connections (profiles)
nmcli connection show

# Show all devices and their status
nmcli device status

# Show full details for a connection
nmcli connection show "ens3"

# Show device details including current IP
nmcli device show ens3

# View with ip command
ip addr show
ip addr show ens3

# View routing table
ip route show

# View default gateway
ip route show default

Step 2 — Configure a Static IP Address with nmcli

This is the most common task when provisioning a server. Replace ens3, the IP address, gateway, and DNS with your actual values:

# Identify your interface name
nmcli device status

# Modify an existing connection to use a static IP
nmcli connection modify ens3 
    ipv4.method manual 
    ipv4.addresses "203.0.113.10/24" 
    ipv4.gateway "203.0.113.1" 
    ipv4.dns "8.8.8.8 8.8.4.4"

# Apply the changes
nmcli connection down ens3 && nmcli connection up ens3

# Verify
ip addr show ens3
ip route show

Step 3 — Configure DHCP

# Switch from static to DHCP
nmcli connection modify ens3 
    ipv4.method auto 
    ipv4.addresses "" 
    ipv4.gateway "" 
    ipv4.dns ""

nmcli connection down ens3 && nmcli connection up ens3

ip addr show ens3

Step 4 — Create a New Network Connection Profile

# Create a new static connection for an interface
nmcli connection add 
    type ethernet 
    con-name "static-ens4" 
    ifname ens4 
    ipv4.method manual 
    ipv4.addresses "10.0.0.5/24" 
    ipv4.gateway "10.0.0.1" 
    ipv4.dns "10.0.0.53"

# Activate the new connection
nmcli connection up "static-ens4"

# Set connection to auto-connect on boot
nmcli connection modify "static-ens4" connection.autoconnect yes

Step 5 — Add a Secondary IP Address

# Add a second IP to an existing connection
nmcli connection modify ens3 
    +ipv4.addresses "203.0.113.20/24"

nmcli connection up ens3

# Verify both IPs
ip addr show ens3

# Remove the secondary IP
nmcli connection modify ens3 
    -ipv4.addresses "203.0.113.20/24"

nmcli connection up ens3

Step 6 — Configure DNS Servers and Search Domains

# Set multiple DNS servers
nmcli connection modify ens3 
    ipv4.dns "1.1.1.1 8.8.8.8" 
    ipv4.dns-search "example.com internal.example.com"

nmcli connection up ens3

# Verify DNS configuration
cat /etc/resolv.conf

# Test DNS resolution
dig example.com
nslookup example.com

Step 7 — Add Static Routes

# Add a persistent static route via nmcli
nmcli connection modify ens3 
    +ipv4.routes "192.168.100.0/24 10.0.0.1"

nmcli connection up ens3

# View routes
ip route show

# Add a temporary route with ip command (not persistent)
ip route add 192.168.200.0/24 via 10.0.0.1 dev ens3

# Delete a route
ip route del 192.168.200.0/24

# Remove a persistent route from nmcli
nmcli connection modify ens3 
    -ipv4.routes "192.168.100.0/24 10.0.0.1"

Step 8 — Rename a Network Connection

# Rename a connection profile
nmcli connection modify ens3 connection.id "production-ens3"

# List to confirm
nmcli connection show

Step 9 — Troubleshoot Connectivity

# Ping tests
ping -c 4 8.8.8.8          # Test internet reachability
ping -c 4 203.0.113.1      # Test gateway reachability
ping -c 4 example.com      # Test DNS + connectivity

# Trace route to a host
traceroute 8.8.8.8
# Or with mtr (install with: dnf install -y mtr)
mtr 8.8.8.8

# Show open network connections
ss -tulpn

# Show only listening ports
ss -tlnp

# Check if a port is reachable
nc -zv 203.0.113.5 443

# View ARP cache
ip neighbour show

# Flush IP address from an interface (temporary — not persistent)
ip addr flush dev ens3

# Restart NetworkManager
systemctl restart NetworkManager

Step 10 — Configure an Interface with ip (Temporary)

The ip command is ideal for temporary changes and testing before committing a configuration persistently with nmcli:

# Assign an IP address temporarily
ip addr add 203.0.113.10/24 dev ens3

# Bring interface up/down
ip link set ens3 up
ip link set ens3 down

# Set default gateway temporarily
ip route add default via 203.0.113.1

# Delete default gateway
ip route del default

# Show network statistics
ip -s link show ens3

Verification Checklist

# Active connections
nmcli connection show --active

# IP addresses
ip addr show

# Routing table
ip route show

# DNS
cat /etc/resolv.conf

# Connectivity
ping -c 2 8.8.8.8 && echo "Internet: OK"

Conclusion

Your RHEL 9 network configuration is now fully under control: static IP addresses and DNS configured with nmcli for persistent profiles, secondary IPs and static routes added and removed, connectivity testing with ping, traceroute, ss, and nc, and temporary changes with the ip command for testing before committing. Understanding the distinction between persistent nmcli profiles and temporary ip changes prevents configuration drift and ensures your network survives reboots as intended.

Next steps: How to Configure the Firewall with firewalld on RHEL 9, How to Configure /etc/hosts and DNS Resolution on RHEL 9, and How to Set Up SSH Key-Based Authentication on RHEL 9.