Solved: How to use nmcli for adding new IP and managing network in Redhat Linux

In our last post we have seen how to use nmtui for network management. In this post we will see how to use nmcli for doing the same activity.

“nmcli” is a command line interface. Benefit with both nmtui and nmcli is that you don’t have to update the network configuration files manually. All the required changes are done by nmtui and nmcli themselves.

Good thing with nmcli is that you don’t have to install any extra package like nmtui. nmcli is generally included with NetworkManager.

  • Let’s create our new connection.
[root@cloudvedas ~]# nmcli con add type ethernet con-name cldvds-2 ifname enp0s3 ip4 gw4
Connection 'cldvds-2' (33de1c00-4ab4-4777-0a43-c004f0bd47ff) successfully added.
[root@cloudvedas ~]#

In the above example we are using these parameters:-

Connection name:- cldvds-2

Network Interface:- enp0s3



  • Check in nmcli if our new connection is present.
[root@cloudvedas ~]# nmcli con show
NAME                 UUID                                 TYPE       DEVICE
System enp0s8    00cb8200-feb0-44b7-a378-3fdc720e0bc7 802-3-ethernet enp0s8
enp0s3           1a03478c-0307-4f23-a7fa-247ad74c37bf 802-3-ethernet --
cldvds-1         303ccf07-e77c-4770-b787-370407f73edc 802-3-ethernet enp0s3
cldvds-2         33de1c00-4ab4-4777-0a43-c004f0bd47ff 802-3-ethernet --
[root@cloudvedas ~]#

We can see the new connection cldvds-2 is created.

  • Activate the new connection
nmcli con up cldvds-2
  • If you are following up from the last post we will first deactivate our old connection cldvds-1 and then activate our new connection cldvds-2 .
[root@cloudvedas network-scripts]# nmcli con down cldvds-1 ; nmcli con up cldvds-2
  • Let’s check if our ip got plumbed

Yes we can see the new IP up and running

  • As I said earlier “nmcli” will automatically update the config file. You can find the file in the directory “/etc/sysconfig/network-scripts” . Cross check the contents of the file
cd /etc/sysconfig/network-scripts
cat ifcfg-cldvds-2

You can also modify the connection properties. Let’s say you want to add DNS server to the connection we created.

[root@cloudvedas ~]# nmcli con mod cldvds-2 ipv4.dns ""

If you want to assign IP using DHCP you can create a new dhcp connection

[root@cloudvedas ~]# nmcli con add type ethernet con-name dhcp-1 ifname enp0s3

You can activate the new dhcp connection.(Be careful because if you are connected with the same interface which you are changing, you will lose the connection.)

nmcli con down cldvds-2 ; nmcli con up dhcp-1


If you want to add an IPv6 IP to the interface you can do it with ip6 and gw6 options.

[root@cloudvedas ~]# nmcli con add type ethernet con-name cldvds-ip6 ifname enp0s3 ip4 gw4 ip6 fe80::cafe gw6 2001:db8::1
Connection 'cldvds-ip6' (83fb7f17-fc2f-424c-b446-33c929abcb56) successfully added.

Activate the connection

[root@cloudvedas ~]# nmcli con down cldvds-2 ; nmcli con up cldvds-ip6

If you no longer need a connection you can delete it after deactivating it.

[root@cloudvedas ~]# nmcli con down cldvds-ip6
[root@cloudvedas ~]# nmcli con delete cldvds-ip6

Hope this post is helpful to you. Do let me know if you have any query.

Solved: How to use nmtui and nmcli tool to configure network in Redhat Linux

In this post we will see how to use nmtui for network management. This can be a very useful tool for starters in Redhat Linux 7.

  • Login to your server using putty and execute command “nmtui” to invoke the interface. If your machine is not in network you can login via console and follow the same steps mentioned below.
  • If you don’t have the nmtui tool installed, you can install it using yum (Note: If you don’t want to install a new package in your server you can use nmcli for network configuration. Refer the post for how to configure network with nmcli )
[root@cloudvedas ~]# yum install NetworkManager-tui
[root@cloudvedas ~]# nmtui
  • Once you get the interface you can navigate using Arrow keys , Tab key and make selection using “enter” key. So, using arrow key select “Edit a connection” and press enter.

  • We have two network interfaces enp0s8 and enp0s3 . Today we will be configuring enp0s3. As enps0s8 is already configured and in use. So once highlighted enp0s3 go to “Add” and press enter.

  • Select the type of connection. For this tutorial we are selecting “Ethernet”.

  • Once in “Edit connection” section enter “Profile name” , “Device”.  If you want static IP select “Manual” for IPv4 and select “Show”.

  • Once you select  “Show” enter your IP detail with subnet id. Here subnet id is /24 or . Also enter gateway. If you want to use DNS enter DNS server details else leave it blank and select OK.

  • Once the IP configuration is done select “OK” again. Now you can see the new connection that you have created. Select “Quit” to come out.

  • Now let’s activate the connection. Execute “nmtui” in putty or console again and select “Activate a connection”  and press Enter.

  • Navigate with arrow key select the interface and then move right and Press enter on “Activate”. This will activate your interface as in image below.

  • Check if the new IP is configured.

  • Also let’s check in “nmcli” about the new connection.

If you want to change hostname refer this post on how to change hostname with nmtui or nmcli .

Hope this post is helpful. Do let me know if you have any query.