I am trying to write a bash script to configure a number of network interfaces and have issues with some of the NICs getting a Wired Connection name instead of the device name. E.g.

$ nmcli dev status
ens22   ethernet  connected  ens22              
ens18   ethernet  connected  Wired connection 2 
ens19   ethernet  connected  ens19              
ens20   ethernet  connected  Wired connection 1 
ens21   ethernet  connected  ens21              
lo      loopback  unmanaged  --     

The impact of that is these commands fail because it is expecting the Connection Name, not the Device Name:

printf "\n${YELLOW}### Configure ens20: ###${NC}\n"
sudo nmcli con mod ens20 ipv4.addresses
sudo nmcli con mod ens20 ipv4.dns
sudo nmcli con mod ens20 ipv4.method manual


  1. What causes only some of the interfaces to get the name "Wired Connection?"
  2. Is there an option in nmcli to use the interface name instead?
  3. Is it possible to rename a connection? I have tried to rename the Connection attribute but I can only do it if I modify the connection, not the device.

This works:

sudo nmcli connection modify "Wired connection 2" connection.id "ens18"

This does not work:

sudo nmcli device modify ens18 connection.id "ens18" 



1 Answer 1


In NetworkManager terminology, a device is the NIC (or a virtual abstraction of one), and a connection is a set of network configuration parameters that can apply to any suitable device, unless specifically restricted to match a particular device only. Even if so restricted, the connections and devices are separate configuration objects.

1.) Wired connection <number> is the default connection name format used by some GUI tools (including the RHEL OS installer), while <interface name> might be the default name used when creating a new connection using nmcli and not specifying a name for it - e.g. if you use nmcli device connect <interface name> and there is no existing connection definition that can apply to that interface.

2.) The only ways to refer to a particular connection are by its name, its UUID, or by its D-Bus connection path number (path <N> for /org/freedesktop/NetworkManager/Settings/<N>, or apath <N> for /org/freedesktop/NetworkManager/ActiveConnection/<N>).

If you want a quick way to refer to "whatever is the active connection on this device", you could make a shell function like this:

nm_connection_of() {
    # $1 = name of network interface to query
    con_name=$(nmcli -g GENERAL.CONNECTION device show "$1")
    if [ "$con_name" = "" ]; then
        echo "ERROR: no connection associated with $1" >&2
        return 1
    echo "$con_name"

Then you could use it like this:

sudo nmcli connection modify "$(nm_connection_of ens18)" connection.id ens18

Note that it's possible that a network interface is not currently associated with any connection at all, in which case $(nm_connection_of <interface name>) would return an error.

3.) You already answered this question yourself.

To rename a connection, you must un-ambiguously identify the connection you wish to rename, not a device that might be associated with any number of possible connections, or with no connection at all.

  • 1
    Thanks. That was a terrific explanation. It shows how important a meta understanding is when trying to do system administration activities.
    – Bryon
    Dec 17, 2021 at 19:06
  • Follow up question. Now I understand connection… would it be reasonable to say that you would use connection.id to be the purpose of the connection. Eg one interface is for WAN another for LAN. Therefore assign connection ids of WAN and LAN?
    – Bryon
    Dec 17, 2021 at 19:36
  • Yes, that would be a good way to name the connections.
    – telcoM
    Dec 18, 2021 at 2:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .