Configure Network Connection Using ‘nmcli’ Tool

Abbreviated as nmcli, the network manager command-line interface is a nifty and easy to use tool that saves you lots of time when you need to configure an IP address.

To display all the active network interfaces on your Linux system execute the command.

$ nmcli connection show
$ nmcli con show

Note that con is the truncated form of connection and you will still end up with the same result as shown.

Check Active Network Interfaces

Check Active Network Interfaces

Also, you can run the command below to display both active and inactive interfaces.

$ nmcli dev status
Check All Network Interfaces

Check All Network Interfaces

Set Static IP Address Using nmcli Tool

Using nmcli tool, you can modify a network interface to use a static IP address. In this example, we will modify the network interface enps03 to use a static IP.

But first, let’s check the IP address using IP command.

$ ip addr
Check Network IP Address

Check Network IP Address

The current IP address is with a CIDR of /24. We are going to configure a static IP with the following values:

IP address:
Default gateway:
Preferred DNS:
IP addressing 		  static

First, run the command below to set up the IP address.

$ nmcli con mod enps03 ipv4.addresses

Next, configure the default gateway as shown:

$ nmcli con mod enps03 ipv4.gateway

Then set up the DNS server:

$ nmcli con mod enps03 ipv4.dns “”

Next , change the addressing from DHCP to static.

$ nmcli con mod enps03 ipv4.method manual
Set Static IP in RHEL 8

Set Static IP in RHEL 8

To save the changes, run the command

$ nmcli con up enps03
Active IP Address of Network

Active IP Address of Network

The changes will be written to /etc/network-scripts/ifcfg-enps03 file.

To confirm the IP, once again run the command:

$ ip addr enps03
Check IP Address

Check IP Address

Additionally, you can view the /etc/network-scripts/ifcfg-enps03 file using cat command.

$ cat /etc/network-scripts/ifcfg-enps03
View Network Interface File

View Network Interface File

And this concludes this guide on configuring network connection using ‘nmcli’ command-line tool on Linux. We hope you found this guide helpful.


source Tecmint

Add a Comment