How to Configure Network Interface Settings with nmcli on RHEL 7
Network configuration on RHEL 7 is managed by the NetworkManager service, and the primary command-line interface for NetworkManager is nmcli. Unlike directly editing /etc/sysconfig/network-scripts/ files — which still works but is error-prone — nmcli provides a structured, validated way to create, modify, and activate network connections. This guide covers everything from checking device status and viewing existing connections to creating Ethernet connections with static IP addresses, and using the interactive nmtui interface as an alternative to the command line.
Prerequisites
- A RHEL 7 system with NetworkManager installed and running
- Root or
sudoaccess - Knowledge of your network settings: IP address, subnet mask, default gateway, and DNS servers
Step 1: Verifying NetworkManager Is Running
Before using nmcli, confirm that NetworkManager is active:
# Check NetworkManager service status
sudo systemctl status NetworkManager
# Enable NetworkManager to start at boot (usually already enabled on RHEL 7)
sudo systemctl enable NetworkManager
# Start NetworkManager if it is not running
sudo systemctl start NetworkManager
# Check the nmcli version
nmcli --version
Step 2: Viewing Device and Connection Status
The nmcli command organizes its output around two concepts: devices (physical or virtual network interfaces) and connections (configuration profiles applied to devices).
Device Status
# Show all network devices and their state
nmcli device status
# Shorthand
nmcli dev status
# Show detailed information about all devices
nmcli device show
# Show details for a specific device
nmcli device show eth0
Example output of nmcli device status:
DEVICE TYPE STATE CONNECTION
eth0 ethernet connected System eth0
eth1 ethernet disconnected --
lo loopback unmanaged --
Connection Status
# List all saved connection profiles
nmcli connection show
# Shorthand
nmcli con show
# Show only active connections
nmcli con show --active
# Show all settings for a specific connection profile
nmcli con show "System eth0"
Step 3: Creating a New Ethernet Connection
Use nmcli con add to create a new connection profile. The following example creates a connection named eth0-static for the eth0 interface:
# Create a basic Ethernet connection profile
sudo nmcli con add type ethernet con-name "eth0-static" ifname eth0
This creates the profile with DHCP configured by default. In the following steps we will configure it for a static IP address.
Step 4: Configuring a Static IP Address
To assign a static IP, you need to set the IPv4 method to manual and provide the address, gateway, and DNS servers. These can be set all at once during connection creation, or modified on an existing connection with nmcli con modify.
Set a Static IP During Connection Creation
sudo nmcli con add
type ethernet
con-name "eth0-static"
ifname eth0
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"
Modify an Existing Connection Profile
# Set the addressing method to static (manual)
sudo nmcli con modify "eth0-static" ipv4.method manual
# Assign the static IP address with CIDR prefix length
sudo nmcli con modify "eth0-static" ipv4.addresses "192.168.1.100/24"
# Set the default gateway
sudo nmcli con modify "eth0-static" ipv4.gateway "192.168.1.1"
# Set primary and secondary DNS servers (space-separated)
sudo nmcli con modify "eth0-static" ipv4.dns "8.8.8.8 8.8.4.4"
# Set DNS search domain
sudo nmcli con modify "eth0-static" ipv4.dns-search "example.com"
# Disable IPv6 if not needed
sudo nmcli con modify "eth0-static" ipv6.method ignore
Additional Static IP Settings
# Add a second IP address to the same interface
sudo nmcli con modify "eth0-static" +ipv4.addresses "192.168.1.101/24"
# Remove a secondary IP address
sudo nmcli con modify "eth0-static" -ipv4.addresses "192.168.1.101/24"
# Set connection to auto-connect on boot
sudo nmcli con modify "eth0-static" connection.autoconnect yes
Step 5: Bringing Connections Up and Down
After creating or modifying a connection profile, activate it with nmcli con up. Changes do not take effect until the connection is reactivated:
# Activate a connection profile (brings the interface up with those settings)
sudo nmcli con up "eth0-static"
# Deactivate a connection (brings the interface down)
sudo nmcli con down "eth0-static"
# Bring up a connection on a specific device
sudo nmcli con up "eth0-static" ifname eth0
# Restart a connection (down then up)
sudo nmcli con down "eth0-static" && sudo nmcli con up "eth0-static"
Verify the interface now has the correct IP address:
ip addr show eth0
ip route show
Step 6: Managing Connections — Delete, Clone, and Reload
# Delete a connection profile
sudo nmcli con delete "eth0-static"
# Reload all connection profiles from disk (useful after manual file edits)
sudo nmcli con reload
# Show a one-line summary of a connection
nmcli -f NAME,UUID,TYPE,DEVICE con show
# Export connection details to a readable format
nmcli -p con show "eth0-static"
Step 7: Configuring a VLAN or Bonding (Advanced)
# Create a VLAN interface (VLAN ID 10 on top of eth0)
sudo nmcli con add type vlan con-name "eth0.10" ifname eth0.10 dev eth0 id 10
sudo nmcli con modify "eth0.10" ipv4.method manual ipv4.addresses "10.10.10.5/24"
sudo nmcli con up "eth0.10"
# Create a network bond (active-backup failover)
sudo nmcli con add type bond con-name bond0 ifname bond0 mode active-backup
sudo nmcli con add type ethernet con-name bond0-slave1 ifname eth0 master bond0
sudo nmcli con add type ethernet con-name bond0-slave2 ifname eth1 master bond0
sudo nmcli con up bond0
Step 8: Using nmtui for Interactive Configuration
If you prefer a menu-driven interface over the command line, nmtui provides a full-screen text UI for NetworkManager. It is part of the NetworkManager-tui package:
# Install nmtui if not already present
sudo yum install -y NetworkManager-tui
# Launch the interactive interface
sudo nmtui
The nmtui main menu offers three options:
- Edit a connection — Create or modify connection profiles with a form-based interface
- Activate a connection — Toggle connections on or off
- Set system hostname — Change the system’s hostname persistently
Navigate with arrow keys, select items with Enter, and use Tab to move between fields and buttons. nmtui is especially useful when working on a remote console without a graphical desktop.
Step 9: Understanding /etc/sysconfig/network-scripts/ Files
When NetworkManager saves a connection, it writes a corresponding configuration file in /etc/sysconfig/network-scripts/. These files can be read, backed up, and in some cases directly edited (followed by nmcli con reload):
# List connection files
ls /etc/sysconfig/network-scripts/ifcfg-*
# View the configuration file created by nmcli for eth0-static
cat /etc/sysconfig/network-scripts/ifcfg-eth0-static
A typical static IP ifcfg- file generated by NetworkManager looks like:
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
NAME=eth0-static
UUID=a1b2c3d4-e5f6-7890-abcd-ef1234567890
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.1.100
PREFIX=24
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=8.8.4.4
DOMAIN=example.com
If you edit this file directly, reload NetworkManager to pick up the changes:
sudo nmcli con reload
sudo nmcli con up "eth0-static"
Step 10: Setting the System Hostname
NetworkManager also manages the system hostname on RHEL 7. Set it persistently with:
# Set the hostname using hostnamectl (recommended)
sudo hostnamectl set-hostname server01.example.com
# Verify the change
hostnamectl status
# Alternatively, set via nmcli
sudo nmcli general hostname server01.example.com
Conclusion
nmcli is the definitive tool for network configuration on RHEL 7, providing a consistent, validated interface to NetworkManager that avoids the common mistakes associated with manually editing /etc/sysconfig/network-scripts/ files. Whether you need to configure a simple DHCP workstation, a server with multiple static IP addresses, a bonded failover pair, or a VLAN-tagged interface, nmcli handles it all from the command line. Pair it with nmtui for interactive sessions and always verify changes with ip addr show and ip route show to confirm the network stack reflects your intended configuration before proceeding with other services.