The nm-connection-editor command on Linux

This tutorial explains how to use the nm-connection-editor command to create new connections and manage existing connections on Linux.

NetworkManager manages all network devices and their settings. To manage settings, it offers three utilities: nmcli, nmtui, and nm-connection-editor.

nmcli

The nmcli utility uses the CLI interface. It works on all platforms. You can use it on SSH, terminal, and Desktop. It supports all features of the NetworkManager.

nmtui

The nmtui uses a curses-based application. It works on the terminal and desktop. It supports all necessary features of the NetworkManager.

nm-connection-editor

The nm-connection-editor is a GTK-based application. It is similar to the nmtui utility. It works only on the desktop. It supports all essential features you need to add, remove, and modify network connections stored by Network Manager.

Differences between nmtui and nm-connection-editor

nmtui nm-connection-editor
It is a curses-based application. It is a GTK-based application.
It does not need a GUI environment to run. It needs a GUI environment to run.
You can use it on CLI and GUI. You can use it only on GUI.
It supports all the necessary features of NetworkManager. It supports only essential features of NetworkManager.
You can use it to add new connections, manage existing connections, activate a connection, and change the hostname. You can use it to add new connections and manage existing connections. You can’t use it to activate a connection or change the hostname.

Using the nm-connection-editor

The following command starts the nm-connection-editor utility.

#nm-connection-editor

On the first screen, it lists all network devices and their connections. On the left bottom side of the screen, it has three buttons. You can use these buttons to add a new connection, delete an existing connection, and manage an existing connection.

nm-connection-editor

Adding/creating a new connection

To add a new connection, click the Add button.

add a new connection

The utility supports many types of network devices. You can create a connection for any supported device but can use the connection only if that device is available on the system.

Select Ethernet from the list and click Create

select ethernet device

The next screen allows us to customize the connection. It has many options. Options are organized in tabs. Let's understand the options you need to know for the RHCSA or RHCE exam.

Connection name: - This is the name of the connection.

On the General tab, we have two important options. These options are the following.

Connect automatically with priority

You can create multiple connections for a device but can use only one at a time. If you select this option on all connections, NetworkManager will automatically pick and use the appropriate connection to connect to the network.

For example, suppose you use your laptop at the office and the home. Both places have wi-fi networks. In that case, you can create two connections: one for the home wi-fi network and another for the office wi-fi network. If you select this option on both connections, NetworkManager will automatically select the appropriate connection based on your location. If you use the laptop at home, it will use the connection you created for the home wi-fi network. Or if you use the laptop at the office, it will use the connection you created for the office wi-fi network.

If you have multiple wi-fi networks at the home or office, you can create multiple connections for that location. If you have multiple connections for a single location, you can use the priority option to decide the order in which NetworkManager should use the connections.

NetworkManager picks the connection with the highest priority, first. If the highest priority connection is not available, it selects the second highest priority connection, and so on.

In the LAB environment, we don't need to configure this option. Uncheck this option.

All users may connect to this network

If you select this option, all users can use this connection to connect to the network. If you uncheck this option, only the user who is creating the connection can use this connection.

Keep this option selected.

nm-connection-editor genral tab

As I mentioned earlier, you can create a connection for any supported device but can use that connection only if that device exists on the system. We are creating a connection for an Ethernet device. We can use this connection only if we assign it to a physical Ethernet device.

On the Ethernet tab, select the Ethernet device from the drop-down.

ethernet device

To use a connection to connect the network, we need to assign an IP configuration to it. To assign an IPv4 address, click the IPv4 Settings tab.

Click Method and select Manual. The manual method allows us to configure an IP address manually. If you want this connection to obtain an IP address from a DHCP server, select DHCP.

Click Add and configure the following IP configuration and click Save.

IP address 10.0.0.10
Netmask 255.0.0.0
Gateway 10.0.0.1

ip configuration

To verify the new connection, we can use the nmcli connection show command.

nmcli connection show command

NetworkManager saves all connection files in /etc/sysconfig/network-scripts/ directory. It uses the ifcfg- suffix with the connection name to generate a name for the connection configuration file. For example, if a connection name is CustomCon1, then the file name will be ifcfg-CustomCon1.

You can also view the connection configuration file to verify the entries of a connection.

listing connection configuration file

As mentioned earlier, a device can have multiple connections but can use only the active connection. You can set only one connection active at a time. nm-connection-editor does not have an option to activate the connection. You can use the nm-connection-editor only to create, manage, and delete a connection.

To activate a connection, you can use the nmcli command or nmtui utility. The following command activates the CustomCon1 connection.

#nmcli connection up CustomCon1

activate a connection

After activating the connection, you can use the ip address show [interface name] command to view the IP configuration of the interface.

#ip address show ens160

ip address show command

As we can see in the above output, the interface is using the IP configuration that we assigned to the CustomCon1 connection.

Modifying/updating/editing a connection

To edit a connection, start the nm-connection-editor utility. Select the connection you want to edit and click the edit button.

edit a connection

Change the IP address and click Save.

updating ip address

NetworkManager does not actively monitor connection configuration files. If you make any change in the connection figuration file, you need to force NetworkManager to reread the connection file.

To force NetworkManager to reread the connection configuration file, you can use the nmcli connection down [connection name] and nmcli connection up [connection name] commands.

Deactivate and activate the connection to force NetworkManager to reread the connection file.

After that, you can use the ip address show command again to verify the change.

activate deactivate connections

Deleting/removing a connection

To delete or remove a connection, start nm-connection-editor. Select the connection you want to delete, click the Delete button, and confirm the delete operation.

delete a connection

To verify that the connection has been deleted, we can list all connections again.

verify deleted connection

Key points:-

  • The nm-connection-editor is part of NetworkManager.
  • It works only on a Desktop.
  • It supports all the essential features you need to manage interfaces and connections.

ComputerNetworkingNotes Linux Tutorials The nm-connection-editor command on Linux