In Rocky Linux 9, the nmcli command-line tool (Network Manager Command Line) replaces the traditional ifcfg files that we have been using since Rocky Linux 8. If you can Google “Why nmcli is replacing the ifcfg”, you will find a comprehensive list of key reasons why the transition took place. One thing that I like best is this particular answer
nmcli commands are designed to be easily automated and scripted (e.g., using Ansible), offering better control and error checking (syntax validation) compared to generating flat text files through scripts.
Usage 1a: List the NetworkManager connection profiles
# nmcli con
NAME UUID TYPE DEVICE
ens33 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ethernet ens33
lo yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy loopback lo
Usage 1b: List the Network Devices and their status
# nmcli dev
DEVICE TYPE STATE CONNECTION
ens33 ethernet connected ens33
lo loopback connected (externally) lo
Usage 2a: Disable the connection of ens33
# nmcli con down ens33
Connection 'ens33' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2)
Usage 2b: Enable the connection of ens33
# nmcli con up ens33
Connection 'ens33' successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2)
Usage 2c: Show Connection Details
# nmcli con show ens33
[root@hpc-wfly-rl9 ~]# nmcli con show ens33
connection.id: ens33
connection.uuid: 817c4ac5-49f4-3752-9a16-9d7460bed1c9
connection.stable-id: --
connection.type: 802-3-ethernet
connection.interface-name: ens33
connection.autoconnect: yes
connection.autoconnect-priority: -999
connection.autoconnect-retries: -1 (default)
connection.multi-connect: 0 (default)
connection.auth-retries: -1
connection.timestamp: 1763952141
connection.permissions: --
connection.zone: --
connection.controller: --
connection.master: --
connection.slave-type: --
connection.port-type: --
connection.autoconnect-slaves: -1 (default)
connection.autoconnect-ports: -1 (default)
connection.down-on-poweroff: -1 (default)
connection.secondaries: --
connection.gateway-ping-timeout: 0
connection.ip-ping-timeout: 0
connection.ip-ping-addresses: --
connection.ip-ping-addresses-require-all:-1 (default)
connection.metered: unknown
connection.lldp: default
.....
.....
Usage 3: Set the static IP Address of the Ethernet Connection
# nmcli con mod ens33 ipv4.method manual ipv4.address 10.10.1.2/24 ipv4.gateway 10.10.1.1
# nmcli con up ens33
Usage 4a: Using conn to update DNS (replace manual scripting of /etc/resolv.conf)
# nmcli con mod ens33 ipv4.dns '8.8.8.8,8.8.8.4'
# nmcli con show |grep dns
# nmcli con up ens33
At /etc/resolv.conf, you will notice
# Generated by NetworkManager
search myown.domain.com
nameserver 8.8.8.8
nameserver 8.8.8.4
Usage 4b: Using nmcli to update domain search (replace manual scripting of /etc/resolv.conf)
# nmcli con mod ens33 ipv4.dns-search 'myown.domain.com'
# nmcli con up ens33
Usage 5a: Disable IPv6
# nmcli con mod ens33 ipv6.method "disabled"
# nmcli con up ens33
.....
....
ipv6.method: disabled
ipv6.dns: --
ipv6.dns-search: --
ipv6.dns-options: --
ipv6.dns-priority: 0
ipv6.addresses: --
....
.....
Display the IP settings of the device. If there is no inet6 entry is displayed, IPv6 is disabled on the device.
# ip address show ens33
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
altname enp2s1
inet 192.168.x.x/19 brd 192.168.x.x scope global noprefixroute ens33
valid_lft forever preferred_lft forever
References: