Configure network interface using NMCLI on Ubuntu 22.04 LTS

By default Ubuntu 22.04 LTS Jammy Jellyfish enabled with netplan network configuration using YAML format.

If you are comfortable with using nmcli we need to install Network Manager packages using apt and configure network interfaces with nmcli or nmtui commands.

We may encounter with below error while trying to use Network Manager on Ubuntu servers, it can be rectified by adding a exception.

Error: Connection activation failed: No Suitable device found for this connection (device lo not available because device is strictly unmanaged).

Install required packages

# apt install network-manager -y

Adding Exception for Ethernet Type

Make sure to add the exception by editing global config file.

# vim /usr/lib/NetworkManager/conf.d/10-globally-managed-devices.conf

Add the exception after a comma (,) as follows.
In my case ethernet, similarly add the required type.

except:type:ethernet

Restart the Network Manager to make it effective.

# systemctl restart NetworkManager

Verify Network Status

Now the status of interface will be in active.

# nmcli device
# nmcli connection

Configure Interface

Configure the interface with an IP, gateway and DNS.

# nmcli connection add type ethernet ifname ens160 con-name prod ipv4.addresses 192.168.10.20/24 ipv4.gateway 192.168.10.1 ipv4.dns 192.168.10.100 ipv4.dns-search linuxsysadmins.lan ipv4.method manual ipv6.method ignore autoconnect yes

That’s it.