
nmcli for Beginners: Control Linux NetworkManager from the Terminal
Why Should You Care About nmcli?
Let’s be real: if you’re running a cloud server, Docker host, VPS, or a dedicated box, you’re going to need to wrangle the network at some point. Maybe you’re SSHing in for the first time, or maybe you’re spinning up containers that need custom bridges. Maybe you’re just sick of fighting with ifconfig
and /etc/network/interfaces
files. Whatever the case, nmcli is your new best friend for managing Linux networking from the terminal. It’s the command-line interface for NetworkManager, the de facto standard for network configuration on modern Linux distros.
Why does this matter? Because NetworkManager is everywhere: Ubuntu, Fedora, CentOS, Debian, Rocky, Alma, openSUSE, and more. If you’re renting a VPS or a dedicated server, chances are it’s running NetworkManager. And if you’re not using nmcli, you’re missing out on a ton of power, flexibility, and—let’s be honest—geeky fun.
The Problem: Networking on Linux is a Pain (But It Doesn’t Have to Be)
Here’s the deal: configuring networks on Linux used to be a mess. You had to edit config files, restart services, and pray you didn’t lock yourself out. With containers, virtual machines, and cloud servers, it’s even more complicated. You need to:
- Set static or dynamic IPs
- Manage DNS and gateways
- Bring interfaces up or down on the fly
- Handle Wi-Fi, Ethernet, bridges, bonds, VLANs, and more
- Automate all this in scripts or Ansible playbooks
Enter nmcli: a Swiss Army knife for all things networking, right in your terminal. No GUI required, no more hunting for obscure config files.
Three Big Questions About nmcli
- How does nmcli actually work?
- How do you set it up quickly and easily?
- What are the real-world pros and cons vs. other tools?
How Does nmcli Work? (A Quick Geeky Dive)
At its core, nmcli is a command-line client for talking to the NetworkManager daemon (NetworkManager.service
). When you run nmcli
commands, you’re sending instructions to NetworkManager, which then does the heavy lifting: configuring interfaces, managing connections, and keeping your network up and running.
Key Concepts:
- Devices: Physical or virtual network interfaces (e.g.,
eth0
,wlan0
,docker0
). - Connections: Profiles that define how a device connects (static IP, DHCP, Wi-Fi SSID, etc.).
- States: Devices and connections can be up, down, connected, disconnected, etc.
Think of it like this: Devices are the hardware, Connections are the settings, and States are what’s happening right now.
How nmcli Talks to NetworkManager
- Via D-Bus (an inter-process communication system in Linux)
- nmcli sends commands, NetworkManager applies changes and reports status
- All changes are immediate—no need to restart services or reboot
Setting Up nmcli: Quick Start Guide
Let’s get you up and running, fast. Here’s how to use nmcli for the most common tasks on your server or VM.
1. Check if NetworkManager and nmcli Are Installed
systemctl status NetworkManager
nmcli --version
If not installed, on Ubuntu/Debian:
sudo apt update
sudo apt install network-manager
On CentOS/RHEL/Fedora:
sudo dnf install NetworkManager
2. List All Network Devices
nmcli device status
Shows all interfaces and their states.
3. Show All Connections (Profiles)
nmcli connection show
4. Bring an Interface Up or Down
nmcli device disconnect eth0
nmcli device connect eth0
5. Set a Static IP Address
nmcli connection modify eth0 ipv4.addresses 192.168.1.100/24
nmcli connection modify eth0 ipv4.gateway 192.168.1.1
nmcli connection modify eth0 ipv4.dns "8.8.8.8 8.8.4.4"
nmcli connection modify eth0 ipv4.method manual
nmcli connection up eth0
6. Set DHCP (Dynamic IP)
nmcli connection modify eth0 ipv4.method auto
nmcli connection up eth0
7. Create a New Connection
nmcli connection add type ethernet ifname eth1 con-name my-eth1 autoconnect yes ipv4.method auto
8. Delete a Connection
nmcli connection delete my-eth1
9. Show Active Connections
nmcli connection show --active
10. Quick Wi-Fi Connect (for laptops or Wi-Fi servers)
nmcli device wifi list
nmcli device wifi connect "SSID_NAME" password "yourpassword"
Examples, Cases, and Practical Advice
Positive Case: Cloud VPS with Multiple IPs
Suppose you ordered a VPS with two public IPs. You want to assign both to your server for Docker or web hosting.
- List devices:
nmcli device status
- Add a second IP to eth0:
nmcli connection modify eth0 +ipv4.addresses 203.0.113.2/24
nmcli connection up eth0
Done. No file editing, no service restarts, no drama.
Negative Case: Accidentally Disabling Your SSH Interface
Common mistake: running nmcli device disconnect eth0
while SSHed in via eth0. Oops, you’re locked out! Always double-check which interface you’re using before disconnecting.
Comparison Table: nmcli vs. ifconfig/ip vs. Editing Files
Feature | nmcli | ifconfig/ip | Manual Editing |
---|---|---|---|
Immediate changes | Yes | Yes | No (requires restart) |
Persistent config | Yes | No | Yes |
Scriptable | Yes | Yes | No |
Handles Wi-Fi, VLANs, bridges | Yes | Partial | Complex |
Works with NetworkManager | Yes | No | No |
Beginner Mistakes and Common Myths
- Myth: “nmcli is only for desktops.”
Reality: It’s perfect for servers, headless boxes, and containers. - Mistake: Disabling the interface you’re SSHed into.
Tip: Always checkwho
orip a
to confirm your connection. - Myth: “NetworkManager is bloatware.”
Reality: It’s lightweight and modular. You can use just the CLI tools. - Mistake: Forgetting to set
ipv4.method manual
when assigning a static IP.
Tip: Always specify the method!
Similar Solutions and Utilities
- nmtui: A text-based (curses) UI for NetworkManager. Great for quick TUI config.
- ifconfig/ip: Classic tools, but don’t persist changes or manage profiles.
- systemd-networkd: Alternative to NetworkManager, more “systemd-native.”
- wicked: Used by openSUSE, not as portable.
For most users, nmcli hits the sweet spot for power and usability.
Interesting Facts & Non-Standard Usage
- nmcli can be used in scripts to auto-configure networks on boot, for cloud-init, or for auto-healing in Kubernetes nodes.
- Supports advanced stuff: VLANs, bridges (for Docker/KVM), bonds (for high-availability), and even Wi-Fi hotspots.
- Works over SSH: Perfect for remote management—no GUI needed.
- Can be used in containers (with some caveats) to manage virtual interfaces and bridges.
- Integrates with VPNs: You can create and manage OpenVPN, WireGuard, and other VPN connections right from nmcli.
Automation, Scripting, and New Opportunities
Here’s where nmcli really shines: automation. You can:
- Write shell scripts to bring up/down interfaces on demand
- Integrate with Ansible, Puppet, or Chef for infrastructure-as-code
- Auto-configure network settings in cloud-init for new VPS deployments
- Use in Docker/KVM host scripts to create bridges and VLANs for containers/VMs
- Monitor network status and auto-recover from failures
Example: A script to automatically reconnect a dropped interface:
#!/bin/bash
IFACE="eth0"
if ! nmcli device status | grep -q "$IFACE.*connected"; then
nmcli device connect $IFACE
fi
Stick that in cron
or a systemd timer, and you’ve got self-healing networking!
Statistics: Why nmcli/NetworkManager Is Winning
- Shipped by default on most major Linux distros since 2015+
- Used by millions of cloud servers, desktops, and IoT devices
- Actively developed and maintained (official site)
- Supports IPv6, Wi-Fi, VPN, bridges, bonds, VLANs, and more
Conclusion: Why You Should Use nmcli (and Where)
If you’re running a VPS, dedicated server, Docker host, or any modern Linux box, nmcli is a must-have tool. It’s fast, scriptable, powerful, and works everywhere NetworkManager does (which is almost everywhere). You’ll save time, avoid mistakes, and unlock advanced networking features that were a pain to set up before. Whether you’re a sysadmin, developer, or just a Linux geek, mastering nmcli will make your life easier—and your servers more reliable.
So next time you need to tweak your network, skip the config files and fire up nmcli
. Your future self will thank you.
For more info, check out the official nmcli documentation and start experimenting!

This article incorporates information and material from various online sources. We acknowledge and appreciate the work of all original authors, publishers, and websites. While every effort has been made to appropriately credit the source material, any unintentional oversight or omission does not constitute a copyright infringement. All trademarks, logos, and images mentioned are the property of their respective owners. If you believe that any content used in this article infringes upon your copyright, please contact us immediately for review and prompt action.
This article is intended for informational and educational purposes only and does not infringe on the rights of the copyright owners. If any copyrighted material has been used without proper credit or in violation of copyright laws, it is unintentional and we will rectify it promptly upon notification. Please note that the republishing, redistribution, or reproduction of part or all of the contents in any form is prohibited without express written permission from the author and website owner. For permissions or further inquiries, please contact us.