Linux 101 : The Network Manager - Setting a static IP address using nmcli -
The nmcli tool helps us create and edit connection profiles.
Connection profiles can be "attached" to interfaces through the network manager.
To display the connections on a system and the devices they are attached to, we use the below command:
To modify the "Wired connection 1" connection, we first we turn it off using the below command:
We then edit our connection using the below command:
To see the details of the connection, we use:
We can change the connection id to "static connection" using the below command:
The field "connection.interface-name" indicates to the Network manager the interface to which the changes will apply.
We can see the IPv4 setting using the below command:
We will need to change it to "manual" to tell the system that we will be providing an internet address manually:
Then we set the gateway IP address and the DNS using the below commands:
We then save the changes, using the below:
And we exit using the below:
Now, we can bring our connection back up using the command:
We can check the changes using the command:
To check if our gateway and DNS are working, we could ping an external address as below: