Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

On CentOS 7 or RHEL 7 using NetworkManager, configure the connection profile—not just the interface’s current runtime address—to make a static IPv4 address persistent. You can do this with nmcli commands or the interactive nmtui text interface. You will need the correct interface, IP address and CIDR prefix, gateway, and DNS servers for your network.

Choose nmcli or nmtui

Red Hat’s RHEL 7 System Administrator’s Guide identifies both nmcli and nmtui for configuring network access after installation.

Tool Best suited to How it works
nmcli Shell administration, repeatable commands, and automation Creates or modifies a NetworkManager connection profile from the command line.
nmtui Interactive configuration at a console Provides a text-based interface for editing network settings.

The steps below use nmcli. For either tool, make sure you are changing the profile intended for the interface.

Find the interface and connection profile

List connection profiles and identify the one associated with the interface you want to configure:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
nmcli connection show
nmcli device status

Use the exact connection name and interface name shown on your system. A connection profile is NetworkManager’s persistent configuration; changing an address visible in a runtime interface check alone does not establish the profile’s persistent settings.

Configure a new static IPv4 profile

If the interface does not already have the profile you intend to use, create one. Replace each placeholder with values supplied by your network plan or administrator:

nmcli connection add type ethernet ifname <interface-name> con-name <connection-name> ipv4.method manual ipv4.address <IP>/<prefix> ipv4.gateway <gateway>

The address must include its CIDR prefix, such as the subnet length assigned to that address. The interface, address, prefix, gateway, and DNS values depend on your network. Do not copy an example address from documentation into a live network without confirming it is valid for your subnet.

Set the DNS servers on the new profile, then activate it:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
nmcli connection modify <connection-name> ipv4.dns "<DNS1> <DNS2>"
nmcli connection up <connection-name>

Use the DNS servers appropriate for your environment. If you have only one DNS server, provide that value rather than an invented second server.

Change an existing profile instead

If the intended connection profile already exists, modify it rather than creating a duplicate. Substitute its exact name and your network’s values:

nmcli connection modify <connection-name> ipv4.method manual ipv4.addresses <IP>/<prefix> ipv4.gateway <gateway> ipv4.dns "<DNS1> <DNS2>"
nmcli connection up <connection-name>

Red Hat documents modifying existing profiles with nmcli con mod; nmcli connection modify is the expanded form used here. Confirm the profile name before applying changes, particularly if several connections have similar names.

Account for the default route on multi-interface hosts

If the machine has multiple network interfaces, decide which connection should provide the default route. A secondary connection that must not supply a default route can be configured with:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
CentOs Linux lover T-Shirt with tagline Open Source Os tee T-Shirt
  • This tee is great present. Show your passion for this mindset with this CentOs Shirt! It is an open source Linux distribution which focuses more on stability. You can give this Tee as a gift for young or men and girl.
  • This tee theme with CentOs Logo. Gift idea for friends, co-workers, hackers, geeks, programmers, computer geniuses and sys admins. Furthermore for Christmas, birthday or Father's Day for young or men and girl.
  • Lightweight, Classic fit, Double-needle sleeve and bottom hem
nmcli connection modify <connection-name> ipv4.never-default yes

Apply that setting only when it matches the host’s routing design. Red Hat documents ipv4.never-default yes for this purpose; the corresponding setting in ifcfg context is DEFROUTE=no (Red Hat guidance on preventing a connection from setting a default route).

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Activate carefully, especially over SSH

Bringing a profile up can briefly interrupt connectivity while NetworkManager removes and reassigns IP addresses and routes. If you are connected remotely, expect your SSH session to drop and arrange console or other recovery access before applying the change. Red Hat describes nmcli device reapply <interface> as an option for some changed properties, but it is not interchangeable with reactivating a connection in every configuration (Red Hat guidance on reapplying NetworkManager configuration changes).

Verify the active profile, address, and route

After activation, inspect the profile and active connection, then check the interface address and routing table:

nmcli connection show
nmcli connection show --active
ip addr
ip route
  • In nmcli connection show --active, confirm that the intended profile is active.
  • In ip addr, check that the intended interface has the configured address and prefix.
  • In ip route, check that the route, including the default route where applicable, matches your network design.

The ip commands show current runtime state; the connection profile is where NetworkManager’s persistent settings are configured. If the active connection, address, or route is not what you intended, recheck the profile name and the network values before making another change. Red Hat’s release-specific guide covers post-install network configuration with nmcli and nmtui in its network configuration chapter.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.