NetworkingSystem managementIntermediate24 min read

What Is nmcli in Networking?

Reviewed byJohnson Ajibi· Senior Network & Security Engineer · MSc IT Security

This page mentions older exam versions. See the Current Exam Context and Legacy Exam Context sections below for the updated mapping.

On This Page

Quick Definition

nmcli is a command-line tool for controlling network settings on Linux systems. It lets you view, add, modify, enable, and disable network connections without needing a graphical interface. Think of it as a remote control for your computer's network adapters, Wi-Fi, and Ethernet connections. You type commands, and it changes how your computer connects to networks.

Common Commands & Configuration

Must Know for Exams

nmcli appears prominently in several major IT certification exams, particularly those focused on Linux system administration. For the RHCSA (Red Hat Certified System Administrator) exam, network configuration is a key objective. Candidates must be able to configure network interfaces, set static IP addresses, configure hostnames, and manage network connectivity using nmcli. The exam often includes tasks like “Configure a static IP address for eth0 using nmcli” or “Set up a bond interface using nmcli”. Similarly, the CompTIA Linux+ (XK0-005) exam covers network configuration under Domain 3 (Networking), expecting candidates to demonstrate command-line network management, which includes nmcli.

In these exams, nmcli is often tested through performance-based items (hands-on simulations) where you must execute commands in a live environment. For example, you might be given a scenario: “The server is currently using DHCP but needs a static IP address of 10.0.0.5/24 with gateway 10.0.0.1. Use nmcli to make the change and ensure the connection is active." You would need to know the correct syntax for modifying a connection profile and then bringing it up. Multiple-choice questions may ask about the purpose of specific nmcli subcommands or ask you to identify the correct command to achieve a particular outcome.

The LPIC-1 certification (exam 101-500) also includes networking fundamentals, and while it may also reference ifconfig and route, nmcli (or its older sibling nmtui and nm-connection-editor) is part of the modern toolset. The exam objectives specifically mention controlling network interfaces and connections, and nmcli is the recommended tool on recent distributions. The Red Hat Certified Engineer (RHCE) exam, which involves more advanced automation and troubleshooting, may require using nmcli to configure teaming, bonding, or VLANs, and to write scripts that use nmcli to enforce network policies.

Exam questions often test your understanding of the difference between “connection” and “device” in NetworkManager terminology. For instance, a connection profile is a set of parameters, while a device is the actual hardware interface. You need to know that a single device can have multiple connection profiles (for different networks) but only one can be active at a time. Questions might ask: “Which nmcli command would you use to see the status of all network devices?” (answer: nmcli device status). Or: “How do you delete a connection profile named ‘OfficeWiFi’?” (answer: nmcli connection delete OfficeWiFi).

nmcli is a high-priority topic for Linux certification exams because it is the standard tool for network management on modern enterprise Linux. Mastery of nmcli demonstrates a practical understanding of networking concepts (IP addressing, routing, DHCP, DNS) and the ability to automate and manage systems without a GUI, which is a core competency for any system administrator.

Simple Meaning

Imagine your computer is a house with several doors and windows that connect to the outside world. Some doors are for Wi-Fi, some are for Ethernet cables, and some might be for mobile data. Normally, you might use a control panel on the wall (like a graphical settings window) to open or close these doors, or to switch which one you use. nmcli is like having a set of written instructions you can give to a smart assistant who walks around the house and operates those doors for you. Instead of clicking icons, you type commands.

For example, if you want to connect to a new Wi-Fi network, you could type a command like "nmcli device wifi connect CoffeeShop password secret123". The tool tells NetworkManager, the system service that handles all networking, to scan for available Wi-Fi networks, find the one named CoffeeShop, and connect using the given password. It does all of the behind-the-scenes work of authenticating, getting an IP address, and setting up routing. You don’t need to touch any cables or navigate menus.

nmcli is especially useful for IT professionals because it allows them to manage networks on servers or remote machines that don’t have a screen, mouse, or graphical interface. It is also great for scripting and automation-you could write a script that sets up a network connection exactly the same way on hundreds of computers. In everyday terms, it’s like having a universal remote that works even when the TV is in another room, and you can program it to change channels at specific times. For anyone studying for IT certifications, understanding nmcli is essential because it is a standard tool on almost every modern Linux distribution and appears in many exam scenarios.

Full Technical Definition

nmcli (NetworkManager Command-Line Interface) is a command-line client that communicates with NetworkManager via D-Bus. NetworkManager is a system service that manages network interfaces and connections on Linux systems. It aims to simplify network configuration by handling device detection, connection auto-activation, IP address assignment (via DHCP or static configuration), DNS resolution, and routing. nmcli provides a human-readable interface to control these functions without requiring direct manipulation of configuration files or the D-Bus API.

At its core, NetworkManager maintains a set of connection profiles. Each profile defines the parameters for a specific network connection-such as the interface (e.g., eth0, wlan0), the type (Ethernet, Wi-Fi, bridge, bond, VLAN), security settings (like WPA2-PSK for Wi-Fi), IP addressing method (DHCP or static), DNS servers, and routing rules. nmcli allows you to create, view, modify, activate, deactivate, and delete these profiles. It can also control the state of network devices directly, for example, enabling or disabling Wi-Fi, or disconnecting a device from its current connection.

Technically, nmcli operates over D-Bus, an inter-process communication system. When you issue a command, nmcli sends a D-Bus message to the NetworkManager daemon. The daemon then processes the request and updates its internal state, which in turn updates the kernel’s network configuration via netlink sockets, manages DHCP clients (internal or external like dhcpcd), and controls wpa_supplicant for Wi-Fi security. This architecture means many operations are atomic and consistent with the system’s overall network state.

nmcli supports multiple subcommands, including: nmcli general (status and permissions), nmcli networking (toggle networking on/off), nmcli radio (control Wi-Fi and WWAN radios), nmcli connection (manage connection profiles), nmcli device (manage and monitor network devices), and nmcli monitor (watch for events). For IT certification exams, key practical skills include using nmcli to configure static IP addresses, set up teaming or bonding interfaces, manage VLANs, and debug connectivity issues by inspecting device status and connection details. Understanding nmcli also implies familiarity with concepts like DHCP, DNS, routing tables, and network namespaces, as the tool interacts with all these layers.

Real-Life Example

Think of nmcli as the voice commands for a smart home hub that controls your home’s doors and windows. In a smart home, you have doors (Ethernet ports), windows (Wi-Fi channels), and maybe a security system (VPN or firewall). Normally, you might use an app on your phone or a wall panel to see which doors are locked or open, and to change settings. But if you are away from home and your phone battery dies, you might call your smart home assistant from a friend’s phone and say “Lock the front door” or “Close the garage window.” nmcli is that voice command for your computer’s network.

For example, suppose you are an IT administrator managing a server room with no monitors. You connect via SSH from your laptop. Now, you need to change the server’s IP address from a dynamic (DHCP) to a static one, because the network team assigned a fixed IP. You cannot open a settings window. Instead, you type: "nmcli connection modify eth0 ipv4.method manual ipv4.addresses 192.168.1.100/24 ipv4.gateway 192.168.1.1 ipv4.dns 8.8.8.8" and then "nmcli connection up eth0". Just like telling your smart home assistant to lock the front door and set the thermostat to 72 degrees, you are telling NetworkManager to reconfigure the network interface and apply the changes.

Another everyday analogy: Imagine you have a friend who is a butler for your house. You give written instructions (nmcli commands) to the butler, who then walks around and adjusts things-opens the gate for a Wi-Fi network, checks the lock on the Ethernet door, and reports back the status of each entry point. The butler (NetworkManager) does all the heavy lifting, while you only need to know the right phrases to say. This separation of high-level command and low-level execution is what makes nmcli powerful for automation and remote management.

Why This Term Matters

nmcli matters because modern IT infrastructure relies heavily on Linux servers, and network configuration is a fundamental task that system administrators perform daily. Without nmcli, administrators would have to manually edit configuration files (like /etc/network/interfaces or /etc/sysconfig/network-scripts), restart networking services, and troubleshoot issues using a mix of tools like ifconfig, route, and iwconfig. nmcli provides a unified, consistent, and scriptable interface to NetworkManager, which is the default network management service on most enterprise Linux distributions (RHEL, CentOS, Fedora, Ubuntu, Debian).

In practice, nmcli is used for everything from simple tasks like connecting to a Wi-Fi network on a laptop to complex enterprise configurations like setting up network bonding for redundancy, creating VLAN interfaces for network segmentation, and configuring teaming for load balancing. For example, a data center administrator might use nmcli to ensure that a server automatically uses two network cards as a single bond interface to survive a cable failure. They can script these configurations and deploy them across dozens or hundreds of servers through configuration management tools like Ansible or Puppet.

nmcli is critical for remote management. When a server is headless (no monitor, keyboard, or mouse), the only way to fix a network misconfiguration is through out-of-band management (like iDRAC or IPMI) or by booting into rescue mode. However, if the network is partially working, an administrator can use nmcli over SSH to diagnose and repair the connection without physical access. This capability reduces downtime and allows for faster incident response.

For certification candidates, nmcli is not just a random tool-it is a core component of the Linux networking stack. Exams like the Red Hat Certified System Administrator (RHCSA), CompTIA Linux+, and LPIC-1 include specific objectives around network configuration using nmcli. Understanding nmcli means you understand how NetworkManager works, how connections profiles are stored, and how to troubleshoot common network issues. It is a practical, hands-on skill that directly translates to real-world job responsibilities.

How It Appears in Exam Questions

Exam questions involving nmcli generally fall into three categories: command syntax, troubleshooting, and configuration scenarios. In multiple-choice questions, you might be asked to identify the correct nmcli command to perform a specific action. For example: “Which nmcli command will display all available Wi-Fi networks?” The correct answer is nmcli device wifi list (or nmcli device wifi). Distractors might include nmcli connection show, nmcli device status, or nmcli networking on. Another common pattern: “What does the command nmcli connection modify eth0 ipv4.method manual do?” The answer is it changes the IP assignment method from DHCP to static.

Performance-based or simulation questions are more challenging. A typical scenario might present a system that is currently using DHCP on interface enp0s3. The candidate is asked to change the IP address to 192.168.1.50/24 with gateway 192.168.1.1 and DNS server 192.168.1.1, and then ensure the connection is active. The candidate must execute the proper sequence: nmcli connection modify enp0s3 ipv4.method manual ipv4.addresses 192.168.1.50/24 ipv4.gateway 192.168.1.1 ipv4.dns 192.168.1.1, followed by nmcli connection up enp0s3. A common trap is forgetting to set the method to manual before adding addresses, or failing to bring the connection up after modification.

Troubleshooting questions often involve a scenario where a server cannot connect to the network. The candidate must use nmcli to diagnose the issue. For example, a question might say: “The server is not reaching the internet. Use nmcli to check if the Ethernet device is connected and if it has an IP address.” The correct approach is to run nmcli device status to see if the device is connected, then nmcli connection show to check if the connection is active, and then nmcli connection show eno1 to see the IP configuration. Another possible issue: the Wi-Fi radio is blocked. The question might expect you to use nmcli radio wifi on to enable it.

Another common pattern is configuring advanced networking features. For instance: “Configure a bond interface called bond0 using nmcli with mode active-backup, using devices eno1 and eno2.” The candidate must create a bond connection, set the mode, add the slaves, and then bring it up. The syntax would involve nmcli connection add type bond con-name bond0 ifname bond0 bond.options mode=active-backup; then nmcli connection add type ethernet con-name bond0-slave1 ifname eno1 master bond0; and similarly for eno2; finally nmcli connection up bond0.

Some questions test understanding of nmcli output. For example, the output of nmcli device show might list UUID, type, state, and IP configuration. A question might ask: “Based on the output, which interface has no IP address?” or “Which device is currently in a disconnected state?” Reading nmcli output correctly is a valuable skill.

Finally, exam questions may blend nmcli with other concepts, such as hostname configuration (nmcli general hostname) or network teaming with nmcli. The variety ensures that candidates have practical, not just theoretical, knowledge.

Practise nmcli Questions

Test your understanding with exam-style practice questions.

Practise

Example Scenario

You are a junior system administrator at a small company. The company has a Linux server that runs a customer database. One morning, the senior admin asks you to change the server’s IP address from a dynamic DHCP-assigned address to a static address because the network team needs the server to always have the same IP for monitoring purposes. The server is in a remote data center, so you cannot physically access it. You must connect via SSH and use nmcli to make the change.

You log in to the server via SSH. First, you check the current network configuration: you type nmcli device status to see which interfaces are present. The output shows one Ethernet device named enp0s3, state connected. Then you check the current connection profile: nmcli connection show --active shows that ‘enp0s3’ is the active connection. To see the details of that connection, you type nmcli connection show enp0s3. You note the current IP address is 192.168.1.45 (from DHCP) and the gateway is 192.168.1.1.

Your assignment: change the IP to 192.168.1.100 with a subnet mask of 255.255.255.0 (CIDR /24), gateway 192.168.1.1, and DNS server 8.8.8.8. You carefully type: nmcli connection modify enp0s3 ipv4.method manual ipv4.addresses 192.168.1.100/24 ipv4.gateway 192.168.1.1 ipv4.dns 8.8.8.8. Next, you need to apply the changes. You run nmcli connection up enp0s3 to bring the connection down and then up with the new settings. After a few seconds, you verify by running nmcli connection show enp0s3 again. The output now shows the IP address as 192.168.1.100 and the method as manual. You also run ping 8.8.8.8 to confirm internet connectivity. It succeeds.

This scenario shows the practical flow: assess, modify, apply, verify. It also highlights the importance of precise syntax. If you had forgotten to set ipv4.method to manual, the new addresses would be ignored because the profile would still expect DHCP. If you had typed the CIDR notation incorrectly (e.g., /255.255.255.0 instead of /24), the command would fail. This scenario is exactly the type of task you might be asked to perform in a certification exam’s performance-based section.

Common Mistakes

Confusing connection name with device name

nmcli uses two distinct concepts: the connection profile (which has a name like 'enp0s3' or 'OfficeWiFi') and the device (the physical interface like enp0s3 or wlan0). Mistakes arise when users try to modify a device directly instead of its connection profile, or vice versa.

Always remember: nmcli connection commands operate on profiles; nmcli device commands operate on hardware. If you want to change IP settings, modify the connection profile. If you want to enable or disable a Wi-Fi radio, use device commands.

Forgetting to set ipv4.method to manual before adding static IP

If the connection profile method remains 'auto' (DHCP), adding an IP address via ipv4.addresses will not take effect. NetworkManager will continue to use DHCP. The additional addresses may appear in the configuration but will not be used.

Always change the method first: nmcli connection modify <name> ipv4.method manual. Then add the static address. Or you can do it in a single command, but the method must be set before the connection is brought up.

Not bringing the connection up after modification

Modifying a connection profile only changes the stored configuration. The running interface still uses the old settings until the connection is reactivated. Many users change settings and then wonder why nothing changed.

After any modification to an active connection, run nmcli connection up <connection-name> to reapply the settings. This brings the connection down and back up with the new configuration.

Using wrong syntax for CIDR notation

nmcli expects IP prefixes in CIDR format (e.g., 192.168.1.100/24). Some users incorrectly use a full subnet mask (e.g., 192.168.1.100/255.255.255.0) or forget the mask entirely, leading to errors or unexpected behavior.

Always use CIDR notation: /24 for 255.255.255.0, /16 for 255.255.0.0, etc. If you are unsure, remember that /24 is the most common for local networks. Alternatively, you can specify the gateway separately and accept the default mask from the address, but explicitly stating the CIDR is safer.

Overlooking the difference between nmcli connection reload and nmcli connection up

nmcli connection reload reloads the connection files from disk but does not apply them to running interfaces. Users think reload is enough to change settings, but the old configuration remains active until the connection is brought up after modification.

Understand the command chain: modify, then up. Reload is only needed if you edited files manually outisde of nmcli and want NetworkManager to re-read them. For normal nmcli operations, use 'connection up' to activate changes.

Exam Trap — Don't Get Fooled

{"trap":"On an exam, you are asked to set a static IP address on interface eth0 using nmcli. You type nmcli connection modify eth0 ipv4.method manual ipv4.addresses 192.168.1.10/24 but the system still gets a DHCP address after reboot."

,"why_learners_choose_it":"Learners often think that modifying the connection is enough. They see the command complete without errors and assume the change is permanent. They may also forget to set the connection to 'manual' or fail to bring the connection up after the change.

In some distributions, if the connection is set to 'auto-connect' and there is another active connection, the change might not persist.","how_to_avoid_it":"First, always check the current active connection: nmcli connection show --active. Modify the correct connection (often named after the interface but not always).

After modification, run nmcli connection up eth0 (or the connection name) to apply changes immediately. After reboot, the connection will be activated if auto-connect is yes (default). To ensure the change is permanent, set ipv4.

method to manual, and optionally disable auto-connect for any conflicting connections. Always verify with nmcli connection show eth0 after the change, and after reboot, check the IP with ip addr show eth0."

Commonly Confused With

nmclivsnmcli connection down

nmcli connection down deactivates a connection profile, meaning the interface stops using that configuration. It does not delete the profile, and it can be reactivated later. nmcli connection up does the opposite. A common confusion is that 'down' is needed before modifying a connection; it is not strictly required, but it is a safe practice to avoid conflicts.

If you want to temporarily disconnect from Wi-Fi to switch to Ethernet, you might type 'nmcli connection down MyWiFi'. The interface will go down, but the profile still exists. Later, 'nmcli connection up Ethernet' will activate the Ethernet profile.

nmclivsifconfig

ifconfig is a legacy tool for viewing and configuring network interfaces. It is still available on many systems but is deprecated in favor of 'ip' and NetworkManager tools. nmcli is higher-level and works with NetworkManager’s abstraction layers, while ifconfig interacts directly with kernel interfaces. ifconfig does not manage connection profiles or remember settings after reboot, whereas nmcli does when used with NetworkManager.

To set a static IP temporarily with ifconfig: ifconfig eth0 192.168.1.10 netmask 255.255.255.0 up. This change is lost on reboot. With nmcli, the change persists in the connection profile.

nmclivsnmtui

nmtui is the text-based user interface (TUI) for NetworkManager. It provides a menu-driven interface within the terminal, making it easier for users who prefer not to memorize commands. nmcli is strictly command-line. Both ultimately use D-Bus to communicate with NetworkManager. The key difference is that nmcli is better for scripting and automation, while nmtui is for interactive use.

To change the hostname interactively, you might run nmtui and navigate to 'Set system hostname'. Using nmcli, you would type 'nmcli general hostname new-hostname'.

nmclivsip command (ip addr, ip link)

The 'ip' command (from iproute2) is a low-level tool that directly manages network interfaces, addresses, routes, and tunnels. It does not interact with NetworkManager. While nmcli manages connection profiles and relies on NetworkManager, 'ip' commands can bypass NetworkManager, potentially causing inconsistencies. For exam purposes, nmcli is preferred for persistent configuration, while 'ip' is often used for temporary changes or advanced troubleshooting.

To temporarily add an IP address: ip addr add 192.168.1.100/24 dev eth0. To make it permanent, you would use nmcli to modify the connection profile.

Step-by-Step Breakdown

1

Identify the connection and device names

Before making any changes, you need to know the correct connection profile name (e.g., 'enp0s3', 'Wired connection 1', 'WorkWiFi') and the device name (e.g., eth0, wlan0). Use 'nmcli connection show' to list all profiles and 'nmcli device status' to see devices. Confusing these names is a common source of errors.

2

Modify the connection profile

Use the 'nmcli connection modify' command followed by the connection name and the settings you want to change. For example, to set a static IP, you must set the IP method to 'manual' and then specify the address, gateway, and DNS. Multiple settings can be combined in one command. Each parameter change updates the profile stored in /etc/NetworkManager/system-connections/.

3

Deactivate and reactivate the connection

Modifying the profile does not apply changes to the running network interface until the connection is brought down and up again. Use 'nmcli connection down <name>' followed by 'nmcli connection up <name>', or simply 'nmcli connection up <name>' which will automatically deactivate and reactivate if the connection is active.

4

Verify the new configuration

After reactivation, confirm the settings are applied. Use 'nmcli connection show <name>' to see all details, and 'ip addr show <device>' to check the actual IP address. Also test connectivity with ping to a reliable external host, such as 8.8.8.8. Verification ensures the change works as intended and catches any typos or mistakes.

5

Make the change permanent (if needed)

By default, changes made with nmcli are permanent as the profile is saved to disk. However, if the connection is set to not auto-connect, you might need to enable it: 'nmcli connection modify <name> connection.autoconnect yes'. Also, ensure no other connection profile is set to auto-connect and interfere. For server environments, you may want to set 'connection.autoconnect-priority' to ensure the correct profile activates first.

6

Document and test after reboot

For mission-critical servers, always test that the network configuration survives a reboot. Reboot the system and log back in. Check that the interface comes up with the correct IP. If it fails, you may have a misconfigured profile or a conflict with another profile. Troubleshoot by looking at 'nmcli connection show' and checking logs (journalctl -u NetworkManager).

Practical Mini-Lesson

nmcli is more than just a command-it is the primary interface to NetworkManager, which itself is a complex service that manages your system’s network stack. To use nmcli effectively, you must understand the relationship between connections, devices, and the D-Bus message system. Let’s dive into how you would use nmcli in real system administration.

First, know that NetworkManager stores connection profiles as files in /etc/NetworkManager/system-connections/. Each file is a plain text INI-style file containing all settings for a connection. When you run nmcli connection modify, it updates these files. You can also manually edit these files, but then you must run nmcli connection reload to have NetworkManager re-read them. In practice, you almost always use nmcli to avoid syntax errors.

Second, understand the concept of connection UUID. Each profile has a UUID, and you can refer to a connection by its UUID instead of its name, which is useful when names are long or contain spaces. For example, nmcli connection show <UUID>. You can get the UUID from nmcli connection show.

Third, nmcli supports many connection types: ethernet, wifi, bridge, bond, vlan, team, and more. For each type, there are specific options. For instance, for a Wi-Fi connection, you might need to set 802-11-wireless.ssid and 802-11-wireless-security.psk. For a VLAN, you set vlan.id and vlan.parent. For bonding, you set bond.options with mode=active-backup,miimon=100. These options are documented in NetworkManager’s manual, but exam questions will focus on common ones.

Fourth, when troubleshooting, use nmcli device show <device> to see detailed information such as connection speed, duplex, and link detect. The output also shows the current IP configuration, DNS servers, and routes. This is often faster than using ip addr and ip route, especially in a headless environment.

Fifth, scripting with nmcli is powerful. You can combine it with bash loops, case statements, and conditionals. For example, a script to set all Ethernet connections to a static IP might look like: for con in $(nmcli connection show | grep -i ethernet | awk '{print $1}'); do nmcli connection modify $con ipv4.method manual ipv4.addresses ...; done. However, be cautious: changing many connections at once can break network access if done incorrectly.

Finally, what can go wrong? The most common real-world issues are: (1) conflicting connection profiles-if you have two profiles that can connect to the same network, they may cause a loop or connection flapping. (2) Incorrect DNS settings can cause name resolution failures even if the network is up. (3) Using nmcli on a system that does not use NetworkManager (e.g., older System V init systems or systems with systemd-networkd exclusively) will fail. Always verify that the NetworkManager service is running.

nmcli is a robust, network-focused tool that every Linux admin should master. It abstracts away low-level complexity, but requires a solid understanding of networking concepts (IP, DHCP, DNS, bonds, VLANs) to be used effectively. For certification, practice with real systems or virtual machines-create and delete connections, break and fix them, and get comfortable with the command output.

Troubleshooting Clues

Symptom:

Symptom:

Symptom:

Symptom:

Symptom:

Symptom:

Memory Tip

Remember: 'nmcli' stands for NetworkManager Command-Line Interface. Think of it as 'Network My Command Line Interface': if you need to change network settings, you 'command' it with nmcli. For static IP configuration, remember the three M's: Modify, Method (manual), and Up (after).

Learn This Topic Fully

This glossary page explains what nmcli means. For a complete lesson with labs and practice, see the topic guide.

Covered in These Exams

Current Exam Context

Current exam versions that test this topic — use these objectives when studying.

Legacy Exam Context

Older materials may mention these exam versions, but learners should use the current objectives for their target exam.

XK0-005XK0-006(current version)

Related Glossary Terms

Quick Knowledge Check

1.What is the purpose of nmcli in Linux?

2.Which command would you use to see all available network devices and their connection status?

3.After modifying a connection profile with nmcli, what must you do to apply the changes?

4.Which nmcli command correctly configures a static IP address and gateway?