Last Updated on 5 days by Sachin G

When managing servers with a command line interface, nothing is more empowering than mastering nmcli network configuration. Over the years, I’ve used nmcli (Red Hat Network Manager CLI) in various scenarios, ranging from quick static IP assignments on test environments to full network setups without a GUI in RHEL production systems. What makes nmcli so powerful is not just its scriptability but the consistency it offers across both RHEL 8, RHEL 9, and CentOS Stream.

When I first time used nmcli, it was out of necessity. A remote server on Red Hat Enterprise Linux had no GUI no nmtui, and I needed to set a static IP address on a newly provisioned interface. That moment kickstarted my journey into Linux command-line networking, and what felt intimidating at first became second nature over time

Getting Started with nmcli: The Basics

nmcli is a command-line interface to NetworkManager. It lets you manage network interfaces, IP settings, routes, DNS, and more without any GUI tools. It’s ideal for sysadmins managing headless servers or automating network changes.

One of the first questions I faced was: What is nmcli and how does it work in CentOS/RHEL?

Simply put, nmcli interacts with the NetworkManager service to view and modify network connections. It’s the CLI equivalent of GUI tools like nmtui, but much more powerful when working on systems like CentOS Stream or RHEL 9, especially in remote or server environments.

Step-by-Step Network Configuration with nmcli

Let’s walk through a step-by-step network configuration with nmcli that I’ve used countless times in real-world setups. IP command will be used to show device and network address information. List of commands below will generate different types of customized output of address information.

  • Show all interfaces IP address and Netmask information.

# ip addr

Some option of ip addr command as below, execute below command and get specific interface information.

# ip addr show
# ip addr show [Device Name ]

Device Name  :  Network interfaces in Linux can be named as eth0,eth1 and enp2s0.The interface name is based on device topology , firmware and device type like Ethernet interface begin with en and WLAN interface will begin with wl name.

The above command will show all interface device information.

(a) UP showing as active interface.

(b) MAC address of device.

(c) Inet line shows the IPv4 and Netmaks or Prefix information.

(d) Broadcast address

(e) Scope and device name are also on the same line.

(f) This will show IPv6 information.

ipaddr


Display Routing Information

# ip  route
iproute

 Network Device Configuration with nmcli  and Network Manager

NMCLI General Command and its usages.

(a) Below command wil list all connections .

# nmcli con show

(b) Active connection will show with  –active option.

# nmcli con show  --active

(c) You can check device status and details.

# nmcli  dev status

(d) It will show general status of Network Manager.

# nmcli general status
nmclistatus


(e) Now nmcli  will show configuration of connection through below command.

# nmcli con show  “CONNECTION NAME or UUID”

The output of below command is completed. some of content screecast image is below.

showenp3s0

Add a new IP or updatethe Network interface information on existing interface with nmcli

Here we are going to update or change IP address on existing active interface. Be careful with live servers before doing this , you should aware what you are doing, it can be lost network connection and lost remote server , you should have good system administrator knowledge.

Turn on autoconnect 

Below command will  be enable  network device on boot .

# nmcli con mod  “CONNECTION NAME ” connection.autoconnect yes
connection.autoconnect

Add a DNS Server 

# nmcli con mod  “CONNECTION NAME” ipv4.dns [DNS IP]
ipv4.addresses

If you want to add one more DNS as a secondary DNS, you can use the +/- operator in the argument, like the command below.

# nmcli con mod “CONNECTION NAME”  +ipv4.dns [DNS IP]

addipv4.dns

 

Add manual static IP address and gateway

# nmcli con mod "CONNECTION NAME” ipv4.addresses [IP ADDRESS/PREFIX  GATEWAY]

Here 192.168.0.10 is IP Address and 24 is Prefix or net mask and 192.168.0.2 is gateway which I have set .

If you want to add a secondary IP address without a gateway, you can use as below.

# nmcli con mod “CONNECTION NAME”  +ipv4.addresses [IP ADDRESS/PREFIX]
IPV4.address

Now if your connection has been done, this command will save your command setting to the configuration, it will reflect and work after the activated or deactivated connection. Here are the reload configuration and activated and deactivated connection commands below.

ipservices

Connection vs Device in nmcli

There’s often confusion between the terms “connection” and “device.” A device is the actual hardware (e.g., eth0), while a connection is the profile or configuration associated with it.

I ran into this early on when I edited a device directly and wondered why my changes weren’t persistent. Understanding this difference was key in scripting persistent network setups.

Is nmcli Better Than ifconfig or nmtui?

Having used all three, I can confidently say nmcli offers far more power and flexibility. ifconfig is deprecated and lacks features for modern networking. nmtui is great for simple setups but doesn’t scale well for scripting or automation. In every serious deployment I’ve worked on—especially with Red Hat Enterprise Linux or CentOS Stream—nmcli has been the right tool.

About the Author