nmcli – Address Configuration Tool

The nmcli command is a command-line tool that allows users to configure and manage network connections on Linux systems. It is a part of the NetworkManager package and is used to manage various aspects of network connections, including IP addresses, DNS settings, and network interfaces. The nmcli command is a powerful tool that can be used to configure network settings quickly and easily.

Overview

The nmcli command can be used to configure network settings on Linux systems. The command is used to configure network interfaces, IP addresses, DNS settings, and other network-related settings. Here are some examples of how to use the nmcli command:

Set a static IP address for an interface

To set a static IP address for an interface, use the following command:

nmcli con mod <connection-name> ipv4.addresses <ip-address>/<subnet-mask>

For example, to set a static IP address of 192.168.1.100 with a subnet mask of 255.255.255.0 for a connection named eth0, use the following command:

nmcli con mod eth0 ipv4.addresses 192.168.1.100/24

Set DNS servers for a connection

To set DNS servers for a connection, use the following command:

nmcli con mod <connection-name> ipv4.dns <dns-server1> <dns-server2>

For example, to set DNS servers of 8.8.8.8 and 8.8.4.4 for a connection named eth0, use the following command:

nmcli con mod eth0 ipv4.dns 8.8.8.8 8.8.4.4

Set a default gateway for a connection

To set a default gateway for a connection, use the following command:

nmcli con mod <connection-name> ipv4.gateway <gateway-address>

For example, to set a default gateway of 192.168.1.1 for a connection named eth0, use the following command:

nmcli con mod eth0 ipv4.gateway 192.168.1.1

View connection details

To view details about a connection, use the following command:

nmcli con show <connection-name>

For example, to view details about a connection named eth0, use the following command:

nmcli con show eth0

Options

The nmcli command has many options that can be used to configure network settings. Here are some of the most commonly used options:

Option Description
con Manage network connections
dev Manage network devices
radio Manage radio switches
general Show general NetworkManager status
monitor Monitor NetworkManager status

Troubleshooting Tips

Here are some troubleshooting tips for common issues with the nmcli command:

  • If you are unable to connect to a network, make sure that your network adapter is enabled and that the correct driver is installed.
  • If you are experiencing slow network speeds, try changing the DNS servers to a faster one.
  • If you are unable to connect to a network that requires a password, make sure that you have entered the correct password.

Notes

  • The nmcli command requires superuser privileges to run.
  • The nmcli command can be used to configure both wired and wireless network connections.
  • The nmcli command can be used to configure network settings on both desktop and server versions of Linux.