HOW TO: Use NMCLI (NetworkManager Command-Line Interface).

  • Post last modified:April 5, 2024
  • Reading time:3 mins read
  • Post comments:0 Comments

NMCLI stands for NetworkManager Command-Line Interface. It is a command-line utility for managing NetworkManager, a service that manages network connections on Linux-based operating systems. NMCLI provides a convenient way to configure and manage network connections, interfaces, and settings via the command line, making it especially useful for system administrators and users who prefer command-line interfaces for network configuration tasks.

 


 

List all available connections:

sudo nmcli connection show

 

View detailed connection information:

sudo nmcli connection show <connection_name>

 

Enable or disable a connection:

sudo nmcli connection up <connection_name>
sudo nmcli connection down <connection_name>

 

Create a new connection:

sudo nmcli connection add type <connection_type> ifname <interface_name> con-name <connection_name>

 

Delete a connection:

sudo nmcli connection delete <connection_name>

 

Modify connection properties (e.g., MTU, DNS search domains):

sudo nmcli connection modify <connection_name> <property_name> <value>

 

Set or change IP addressing:

sudo nmcli connection modify <connection_name> ipv4.method manual
sudo nmcli connection modify <connection_name> ipv4.addresses <static_ip>/<subnet_mask>

 

Set the gateway:

sudo nmcli connection modify <connection_name> ipv4.gateway <gateway_ip>

 

Set DNS servers:

sudo nmcli connection modify <connection_name> ipv4.dns <dns_server1> <dns_server2>

 

To change the name of “Wired connection 1″ to something else, eg.”LinuxPi.ca”

sudo nmcli connection modify "Wired connection 1" connection.id "LinuxPi.ca"

 

 

These are just some of the tasks you can perform with NMCLI. It offers many more options for managing network connections, and you can explore additional features and options in the NMCLI manual or by using nmcli --help to see the available commands and options.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.