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
DEVICE TYPE STATE CONNECTION
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 10.70.20.254/24
sudo nmcli con mod ens20 ipv4.dns 8.8.8.8
sudo nmcli con mod ens20 ipv4.method manual
Questions:
- What causes only some of the interfaces to get the name "Wired Connection?"
- Is there an option in nmcli to use the interface name instead?
- 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"
Thanks