nmcli(Network Manager Command Line Tool)
The nmcli con show command can be used to list the active and inactive connections. You can easily see the difference because inactive connections are not currently assigned to a device.
[root@localhost Desktop]# nmcli con show
NAME UUID TYPE DEVICE
virbr0-nic 7337781b-2950-4d98-af35-62788e3723a3 generic virbr0-nic
virbr0 416e2450-5e0c-4c73-8be2-35828712f647 bridge virbr0
eth0 34abaf73-94b1-40c6-93a1-7ef5e5a003d2 802-3-ethernet enp3s0
After finding the name of the connection, you can use nmcli con show followed by the name of the connection to see all properties of the connection.
[root@localhost Desktop]# nmcli con show eth0
we can also use nmcli to show an overview of currently configured devices and the status of these devices. Type, for instance, thenmcli dev status command to show a list of all devices, and nmcli dev show <devicename> to show settings for a specific device.
[root@localhost Desktop]# nmcli dev status
DEVICE TYPE STATE CONNECTION
virbr0 bridge connected virbr0
enp3s0 ethernet connected eth0
virbr0-nic tap connected virbr0-nic
lo loopback unmanaged —
Create DHCP connection by using nmcli command on interface eth0
nmcli con add con-name “dhcp” type ethernet ifname eth0.
We can also add the static ip address by using nmcli command as follows
nmcli con add con-name “static” ifname eth0 autoconnect no type
ethernet ip4 10.0.0.2/8 gw4 10.0.0.1
use nmcli con up “static” to activate the static connection. Switch back to the DHCP connection using nmcli con up “dhcp”.
Add a DNS server to the static connection by using command as follows
nmcli con mod “static” ipv4.dns 10.0.0.1
To add a second item for the same parameters, use a + sign. Test this by adding a second DNS server, using
nmcli con mod “static” + ipv4.dns 22.214.171.124
Using nmcli con mod, you can also change parameters such as the existing IP address. Try this by using
nmcli con mod “static” ipv4.addresses “10.0.0.3/8”
For adding a second IP address you use the + sign again:
nmcli con mod “static” +ipv4.addresses 192.168.1.1/24
After changing connection properties, you need to activate them. To do that,
you can use nmcli con up “static”