Network Manager - nmcli

Network Manager - nmcli 

If your Linux Distribution is using Network Manager, then nmcli is a great interface to configure connections from the command line interface.

View Connections

To view connections using nmcli, use:

# nmcli


# nmcli connection

NAME        UUID                                  TYPE             DEVICE 
docker0     1948720d-d589-4a3f-99d6-5fefcb5a3380  bridge           docker0
Wired connection 1      13f3f876-c0ab-3b31-a086-360d972043d8  802-3-ethernet   enp4s0 
tun0        c4e462c4-89d9-4d6d-8042-2c2eda44c6da  tun              tun0   
virbr0      f3aedff9-2b78-4a7f-b24e-b3d878daefbf  bridge           virbr0 
Droidz      a940b5dd-ac3a-41b8-9d90-ed408c5f0910  802-11-wireless  --     

To see details use the show action with the connection name:

# nmcli connection show Droidz 

Rename Connection

Change the connection name from "Wired connection 1" to "enp4s0" after the device name:

nmcli connection modify Wired\ connection\ 1 con-name enp4s0

Set IP Address

Set a single IP address for the enp4s0 connection:

nmcli connection modify enp4s0 ipv4.addresses

Use Multiple Addresses

Configure multiple IP addresses for the enp4s0 connection:
nmcli connection modify enp4s0 ipv4.addresses \,

Modifying Other Connection Settings

If using BASH shell completion, many other network connections can discovered to modify easily. For example, typing:

nmcli connection modify enp4s0 ipv4. 

and then pressing the TAB key would show: 

ipv4.addresses           ipv4.dhcp-send-hostname  ipv4.dns-search          ipv4.method
ipv4.dad-timeout         ipv4.dhcp-timeout        ipv4.gateway             ipv4.never-default
ipv4.dhcp-client-id      ipv4.dns                 ipv4.ignore-auto-dns     ipv4.route-metric
ipv4.dhcp-fqdn           ipv4.dns-options         ipv4.ignore-auto-routes  ipv4.routes
ipv4.dhcp-hostname       ipv4.dns-priority        ipv4.may-fail 

Setting the Default Gateway

The command for setting the default gateway is:

nmcli connection modify enp4s0 ipv4.gateway

Activating Modified Changes

After changing the configuration of a connection, bring the connection up to activate them:

nmcli connection up enp4s0

Interactive Editing

To use an interactive editing mode from the command line, use the edit action for the connection:

nmcli connection edit enp4s0

Use the  help command to get started with editing. 
Use the describe command to determine what to provide for a setting.

Hot tip: to avoid settings from being appended when set, first remove them. For example to return to a single IP address from multiple addresses, the other addresses must be removed first.

describe ipv4.addresses
remove ipv4.addresses
set ipv4.addresses


The nmtui and nm-connection-editor commands provide a text menu and graphical interface to Network Manager.

No comments:

About Me - WrightRocket

My photo

I've worked with computers for over 30 years, programming, administering, using and building them from scratch.

I'm an instructor for technical computer courses, an editor and developer of training manuals, and an Android developer.