The short answer: use ip for quick, one-off checks and changes to network interfaces, addresses, and routes, and use nmcli when you need persistent, system-wide network configuration managed by NetworkManager. ip is a low-level tool that talks directly to the kernel; nmcli is a higher-level tool that talks to NetworkManager, which then applies settings and keeps them across reboots.
Background: Two Different Layers
Linux networking has two distinct layers. The kernel itself handles the actual network interfaces, IP addresses, and routing tables. Tools like ip (from the iproute2 package) manipulate these kernel objects directly. When you run ip addr add 192.168.1.10/24 dev eth0, the change happens immediately in the kernel, but it is gone after a reboot unless you also edit a config file or run a script.
NetworkManager is a daemon that sits on top of the kernel and provides a higher-level abstraction: connections. A connection is a named profile that stores all settings for a network (IP address, DNS, Wi-Fi SSID, etc.). nmcli is the command-line client for NetworkManager. When you use nmcli connection up "MyWiFi", NetworkManager reads that profile and applies the settings to the kernel, and it will do so automatically at boot if the connection is set to autoconnect.
How Each Command Works
ip is part of the iproute2 suite, which replaced the older ifconfig, route, and arp commands. Its syntax is object-based: ip [object] [command]. Common objects are link (interfaces), addr (IP addresses), and route (routing table). For example:
ip link show– list all network interfacesip addr show– show IP addressesip route show– display the routing tableip link set eth0 up– bring an interface upip addr add 192.168.1.10/24 dev eth0– assign an IP address
nmcli has two main object groups: connection and device. The connection commands manage profiles, while device commands manage the actual hardware. Common examples:
nmcli device status– show all devices and their statenmcli connection show– list saved connection profilesnmcli connection up "Wired"– activate a profilenmcli connection add type ethernet ifname eth0 ipv4.method manual ipv4.addresses 192.168.1.10/24– create a persistent static IP profile
The key difference: ip changes the kernel state directly; nmcli changes NetworkManager’s configuration, which then updates the kernel state.
How to Choose: When to Use Which
There is no universal “best” – it depends on what you are doing. Use this as a rough guide:
- Quick troubleshooting: Use
ip. If your network is down, NetworkManager might not even be running.ip addr showandip route showgive you raw kernel facts instantly. - Persistent configuration: Use
nmclion a desktop or a server that uses NetworkManager. It saves profiles that survive reboots. - Scripting a temporary change: Use
ipif you want the change to last only until the next reboot or service restart. - Wi-Fi connections: Use
nmcli. Managing Wi-Fi withipis painful because you need to handle wpa_supplicant separately.nmcli device wifi connect "SSID" password "..."is far simpler. - Bonding, bridging, VLANs: Both can do it, but
nmclimakes it easier to define persistent configurations. For a quick temporary bridge,ip link addis fine.
Common Problems and How to Avoid Them
One frequent mistake is using ip addr add without removing the old address first, which can leave you with two addresses on the same interface. Use ip addr flush dev eth0 before adding a new one if you want a clean slate.
Another problem: when you use ip to change an IP address, NetworkManager (if running) may not know about it and could override it later. If you see your changes disappearing, check if NetworkManager is managing that interface with nmcli device status. If it says “connected” or “unmanaged,” you may need to use nmcli instead.
A third issue: forgetting that ip changes are not persistent. A common question is “Why did my IP reset after reboot?” – because you used ip instead of nmcli or editing a config file.
Real-World Comparison: A Static IP Example
Suppose you want to set a static IP of 192.168.1.10/24 on eth0, with gateway 192.168.1.1, and have it survive a reboot.
With nmcli (on a NetworkManager system):
nmcli connection modify "Wired" ipv4.method manual ipv4.addresses 192.168.1.10/24 ipv4.gateway 192.168.1.1
nmcli connection up "Wired"
That’s it. The profile is saved and will be applied at boot.
With ip (temporary only):
ip addr add 192.168.1.10/24 dev eth0
ip route add default via 192.168.1.1
This works immediately, but after a reboot you lose it. To make it persistent with ip, you would need to edit /etc/network/interfaces (Debian/Ubuntu) or a netd script, which is more error-prone.
Alternatives and Related Tools
Beyond ip and nmcli, there are other tools you might encounter:
nmtui– a text-based user interface for NetworkManager. Good if you prefer menus.ifconfigandroute– legacy tools, still present on some systems but deprecated.ipreplaces them.systemd-networkd– a different network manager used on some minimal systems. Its command-line tool isnetworkctl, and config files live in /etc/systemd/network.wicked– used on some SUSE systems, with its ownwickedcommand.
If you are on a server without a desktop environment, check whether NetworkManager is even installed. Many minimal cloud images use systemd-networkd or plain ifupdown, in which case nmcli won’t exist and you should use ip plus config files.
Frequently Asked Questions
Is ip replacing ifconfig?
Yes, on modern Linux distributions ip is the standard tool. ifconfig is deprecated and often not even installed by default. The ip command is more powerful and consistent, but it has a steeper learning curve.
Can I use nmcli on a server without a GUI?
Yes, NetworkManager runs fine without a GUI. Many minimal server installs include it. You can check with systemctl status NetworkManager. If it’s not running, you can install it or use ip with config files.
Why does my ip change get overwritten?
If NetworkManager is managing that interface, it periodically applies its connection profiles, which can override manual ip changes. Use nmcli device status to see if the device is “connected” (managed). If so, use nmcli to make changes, or set the device as “unmanaged” with nmcli device set eth0 managed no.
Which command shows my current IP address?
Both. ip addr show shows all interfaces and addresses. nmcli device show gives more detailed info including DNS and routes. For a quick answer, ip -4 addr show filters to IPv4 only.
Is nmcli only for Wi-Fi?
No, nmcli manages all types of network connections: Ethernet, Wi-Fi, bridges, bonds, VLANs, and even VPNs. It’s just as useful for wired connections.
What if I don’t have nmcli installed?
Then you are likely using a system without NetworkManager – maybe a minimal container or an older distro. In that case, use ip for immediate changes and edit your distribution’s network config files (e.g., /etc/network/interfaces or /etc/sysconfig/network-scripts) for persistence.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Hide PHP Version HTTP Header: How To
- CentOS Stream for Developers: A Practical Guide
- Man-Sized 3D Printer? Why You Probably Don’t Need One100.0 cm³/h
- Scroll Horizontally with Mouse Wheel by Holding Shift5.00 min/km
- How to Replace a Game Controller Battery Safely
- iPadOS 16 Supported Devices: Full List