How to Configure a Static IP Address with NetworkManager on RHEL 7

Configuring a static IP address is one of the most fundamental tasks for any Linux system administrator. On Red Hat Enterprise Linux 7, NetworkManager is the default network management daemon, and it provides two powerful tools for managing connections: the command-line interface nmcli and the text-based user interface nmtui. Unlike earlier versions of RHEL that relied entirely on editing configuration files by hand, RHEL 7 encourages the use of NetworkManager utilities to ensure that changes are persisted correctly and that the network stack remains in a consistent state. This guide walks you through the complete process of assigning a static IP address to a network interface, verifying connectivity, and understanding the underlying configuration files that NetworkManager manages on your behalf.

Prerequisites

  • A running RHEL 7 system with root or sudo privileges.
  • At least one active network interface (e.g., ens33, eth0). You can confirm interface names with ip link show.
  • NetworkManager installed and running (systemctl status NetworkManager).
  • The static IP address, subnet mask, default gateway, and DNS server addresses you intend to assign.
  • Basic familiarity with the Linux command line.

Step 1: Identify Your Network Interface and Existing Connections

Before making any changes, identify the name of your network interface and list all existing NetworkManager connections. This ensures you modify the correct connection profile.

# List all network interfaces
ip link show

# List all NetworkManager connection profiles
nmcli connection show

The output of nmcli connection show will display columns including NAME, UUID, TYPE, and DEVICE. The DEVICE column shows which physical interface is bound to each connection profile. Note the NAME of the profile associated with your target interface (e.g., ens33 or System ens33). You will use this name in all subsequent nmcli con modify commands.

# Example output:
NAME            UUID                                  TYPE      DEVICE
ens33           9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04  ethernet  ens33

If the connection profile name contains spaces, wrap it in double quotes in all commands.

Step 2: Set the IPv4 Method to Manual

By default, most connections are set to auto, which means they obtain an address via DHCP. Switch the method to manual to allow static assignment.

nmcli con modify "ens33" ipv4.method manual

This single command updates the in-memory and on-disk representation of the connection profile. No restart is needed yet — you will apply all changes at once in a later step.

Step 3: Assign the Static IP Address and Prefix

Assign the IP address using CIDR notation. The prefix length replaces the traditional subnet mask (e.g., /24 is equivalent to 255.255.255.0).

nmcli con modify "ens33" ipv4.addresses "192.168.1.100/24"

To assign multiple IP addresses to the same interface, separate them with a comma:

nmcli con modify "ens33" ipv4.addresses "192.168.1.100/24,192.168.1.101/24"

Step 4: Set the Default Gateway

nmcli con modify "ens33" ipv4.gateway "192.168.1.1"

The gateway must reside within the same subnet as the assigned IP address. If the gateway is unreachable, default route traffic will fail silently.

Step 5: Configure DNS Servers

Specify one or more DNS resolvers. Separate multiple addresses with a space inside the quoted string.

nmcli con modify "ens33" ipv4.dns "8.8.8.8 8.8.4.4"

NetworkManager will write these values to /etc/resolv.conf automatically when the connection is brought up. You can also set a DNS search domain:

nmcli con modify "ens33" ipv4.dns-search "example.com"

Step 6: Apply the Changes by Bringing the Connection Up

Deactivate and reactivate the connection to apply all queued changes at once.

nmcli con up "ens33"

If the interface was previously managed by DHCP and a lease is still active, you can force a clean restart:

nmcli con down "ens33" && nmcli con up "ens33"

Step 7: Verify the Configuration

Confirm that the static address has been applied and that the default route is correct.

# Verify IP address assignment
ip addr show ens33

# Verify the default route
ip route show

# Test DNS resolution and connectivity
ping -c 3 8.8.8.8
ping -c 3 google.com

The ip addr show ens33 output should display your assigned address with the correct prefix. The ip route show output should include a line similar to default via 192.168.1.1 dev ens33.

Step 8: Inspect the Underlying ifcfg Configuration File

NetworkManager stores connection profiles as ifcfg-* files in /etc/sysconfig/network-scripts/. After using nmcli, you can inspect the file to verify the result or to understand legacy configurations.

cat /etc/sysconfig/network-scripts/ifcfg-ens33

A correctly configured static file will look similar to:

TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=ens33
UUID=9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.1.100
PREFIX=24
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=8.8.4.4

The key directives are BOOTPROTO=none (static), ONBOOT=yes (connect at boot), and the IPADDR, PREFIX, GATEWAY, and DNS* values. You can edit this file directly, but you must reload NetworkManager afterward with nmcli con reload and then bring the connection up again.

Step 9: Using nmtui as an Alternative

If you prefer a menu-driven interface, nmtui (NetworkManager Text User Interface) provides the same functionality in a curses-based UI accessible over SSH.

nmtui

Select Edit a connection, choose your interface, and navigate to the IPv4 configuration section. Change the method from Automatic to Manual, then add the address, gateway, and DNS servers. Save and exit, then select Activate a connection to apply the new settings.

Step 10: Ensure the Connection Starts Automatically at Boot

Verify that the ONBOOT flag is set, which causes NetworkManager to activate this connection when the system starts.

nmcli con modify "ens33" connection.autoconnect yes

You can confirm this is reflected in the connection properties:

nmcli con show "ens33" | grep autoconnect

Configuring a static IP address correctly on RHEL 7 ensures that critical servers — such as web servers, DNS servers, and database hosts — maintain a predictable network address across reboots. By using nmcli, you benefit from automatic persistence of settings, proper integration with NetworkManager’s connection lifecycle, and the safety of having changes validated before they are applied. The underlying ifcfg-ens33 file serves as a human-readable backup and an integration point for scripts and automation tools, giving you full visibility into the network configuration at all times.