+5 votes
291 views
Nmcli command how to install and use on Linux

in Linux / Unix by (550k points)
reopened | 291 views

1 Answer

+3 votes
Best answer

1. How to install and use nmcli in Linux
2. How to configure a static IP address in Linux with nmcli

Managing the network in Linux systems , in general in any operating system, can be a tedious task if we do not have the necessary tools for it, but in the case of Linux systems, a special command has been developed to manage many variables of the network and it is the command “nmcli” which we will talk about in detail in this tutorial..

 

What is nmcli
Nmcli “network manager command-line interface” is a command that was designed with NetworkManager in mind and with a series of parameters to have the possibility of reporting the status of the network to the administrator.

 

With the nmcli command we can create, edit, delete, activate or deactivate network connections , as well as control and also display the status of the network device installed in Linux.

 

 


1. How to install and use nmcli in Linux

 

Step 1

By default nmcli is installed on Linux systems. We can display all the active network interfaces in Linux with any of the following commands:
 nmcli connection shownmcli  with   show  
image

 

Step 2

As a result of this we will obtain the following details:
  • Connection name
  • Active UUID
  • Network type (cable or Wi-Fi)
  • Device

 

To deploy all Linux connections (active and disabled), we will run the following command:

 nmcli dev status 
image

 


2. How to configure a static IP address in Linux with nmcli


Within the administrative tasks of nmcli we have the possibility of establishing a fixed IP address for the equipment. For this we must take into account the device where the change will be applied, in this case it will be the enps03 network interface.

 

Step 1

First, we will execute the command "ip add" to view the current network configuration:

 

image

 

Step 2

In this case we have the following:
  • IP address 192.168.0.21
  • Gateway 192.168.0.255

 

To establish a new IP address in Linux with nmcli we are going to use the following values:

  • IP address 192.168.0.30
  • Gateway 192.168.0.255
  • Primary DNS 8.8.8.8
  • Static IP type

 

First, we will establish the desired IP by executing the following:

 nmcli  with   mod  enps03 ipv4.addresses  192.168   .2   .30  /  24  
image

 

Step 3

Now we are going to configure the gateway:
  nmcli   with   mod   enps03   ipv4   .gateway  192  .168   .0   .1  
image

 

Step 4

Now we are going to establish the DNS server:
  nmcli   with   mod   enps03   ipv4   .dns  "8  .8   .8   .8  " 
image

 

Step 5

After this we are going to configure the IP address from dynamic to static:
 nmcli  with   mod  enps03 ipv4.method  manual  
image

 

Step 6

We apply the changes with the following order:
 nmcli  with  up enps03 
image

 

We can see the message that the connection has been successfully activated..

 

Step 7

We check that the IP address 192.168.0.30 has been established by executing the command "ip add":

 

image

 

Step 8

Alternately we can go, in this case in CentOS 8 to the following directory:
 / etc / sysconfig / network-scripts / 
Step 9

There then we run "cat ifcfg-enp0s3" to see the network properties:

 

 

image

 

There we clearly find the values ​​that we have established.
With nmcli we have a complete level of options to manage our network in the best possible way.

 


by (3.5m points)

Related questions

+4 votes
1 answer
+3 votes
1 answer
asked Oct 5, 2019 in Linux / Unix by backtothefuture (550k points) | 797 views
+3 votes
1 answer
+5 votes
1 answer
+5 votes
1 answer
asked Feb 22, 2020 in Linux / Unix by backtothefuture (550k points) | 332 views
Sponsored articles cost $40 per post. You can contact us via Feedback
10,627 questions
10,759 answers
510 comments
3 users