Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections. While the graphical tools available in Ubuntu make network management accessible to users of all skill levels, nmcli - the command-line interface for NetworkManager - provides a powerful and flexible alternative. Whether you're managing servers, automating tasks, or just prefer the command line, nmcli is an indispensable tool.
This guide will cover the basics of using nmcli to manage network interfaces and settings on Ubuntu 24.04. We'll explore how to view, configure, and troubleshoot network connections using this powerful command.
nmclinmcli is a command-line client for NetworkManager. It allows you to perform all network management tasks that the graphical interface can, and often much more efficiently. The basic syntax of nmcli is:
nmcli [OPTIONS] OBJECT { COMMAND | help } device, connection, or general.show, up, down, add, etc.nmcliTo begin, it's useful to see the current state of your network devices and connections.
To get a general overview of the network status, including connectivity status and overall configuration:
nmcli general status To see a list of all network interfaces (e.g., Ethernet, Wi-Fi, etc.) on your system:
nmcli device status This command displays the device name, type, state, and the associated connection if any.
If you need more detailed information about a specific network interface (e.g., eth0 or wlp2s0), use:
nmcli device show eth0 Replace eth0 with the actual device name you want to inspect.
To activate (bring up) a network interface, use:
nmcli device connect eth0 To deactivate (bring down) a network interface, use:
nmcli device disconnect eth0 Replace eth0 with the appropriate device name.
Connections in NetworkManager are saved configurations for network interfaces. These can be wired, wireless, VPN, etc.
To list all saved network connections:
nmcli connection show This will list all connections along with their UUIDs, types, and device associations.
If you need to add a new Ethernet connection:
nmcli connection add type ethernet ifname eth0 con-name "Wired Connection" To connect to a Wi-Fi network, use:
nmcli device wifi list This command will list all available Wi-Fi networks. Then, connect to a specific network with:
nmcli device wifi connect "SSID_name" password "your_password" Replace "SSID_name" with the network's SSID and "your_password" with the Wi-Fi password.
If you want to remove a saved network connection:
nmcli connection delete "Wired Connection" Replace "Wired Connection" with the name or UUID of the connection you wish to delete.
nmcli UsageIf you need to modify an existing connection, you can use the edit command:
nmcli connection edit "Wired Connection" This command opens an interactive session where you can modify connection parameters.
To configure a static IP address for an Ethernet connection:
nmcli connection modify "Wired Connection" ipv4.addresses "192.168.1.100/24"
nmcli connection modify "Wired Connection" ipv4.gateway "192.168.1.1"
nmcli connection modify "Wired Connection" ipv4.dns "8.8.8.8 8.8.4.4"
nmcli connection modify "Wired Connection" ipv4.method manual Finally, bring the connection up with:
nmcli connection up "Wired Connection" To create a Wi-Fi hotspot on your system:
nmcli device wifi hotspot ifname wlp2s0 ssid MyHotspot password "mypassword" This command sets up a Wi-Fi hotspot with the given SSID and password. Replace wlp2s0 with your Wi-Fi interface name.
nmcliTo view detailed logs and troubleshoot network issues, use:
nmcli connection show --active Then, for more detailed logs, you can use the journalctl command, which integrates with NetworkManager:
journalctl -u NetworkManager -f If you're encountering persistent issues, resetting the NetworkManager configuration can help:
sudo systemctl restart NetworkManager Or, reload the configuration without restarting:
nmcli networking off
nmcli networking on nmcli is a versatile and powerful tool for managing network interfaces and settings on Ubuntu 24.04. Whether you're configuring a server, setting up a Wi-Fi connection, or troubleshooting network issues, mastering nmcli will give you greater control and efficiency in managing your network. With the commands and tips provided in this guide, you should be well-equipped to handle a variety of networking tasks directly from the command line.
Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…
ISPConfig is an open-source control panel that allows users to manage multiple servers from a…
As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…
Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…
phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…
In the IT world, it is important to keep a copy of your data as…