How to Configure a Static IP Address on Rocky Linux
The default way to modify the IP address of Rocky Linux is through the NetworkManager connection profile using nmcli. First, check and distinguish the currently active connection name and device name. If it is a remote server, ensure access via a console or alternative management path before making changes to prevent disconnection.
Check current network status
Check the device status, connection profile, and actual IP/path in order. DEVICE is the physical or virtual interface name, and NAME is the connection profile name to be modified.
nmcli device status nmcli connection show --active ip -brief address ip route
In the example below, the connection profile name is assumed to be System eth0. Replace it with the name used in your actual environment.
Set a static IPv4 address
Record and back up configuration values
Before making changes, record the current values of the profile. The output may contain sensitive information, so review the contents before sharing externally.
nmcli connection show 'System eth0' sudo nmcli connection export 'System eth0' ./system-eth0.nmconnection
Not all connection types support export. Even if export fails, you can separately store the nmcli connection show results and existing key files in a safe location.
Enter address, gateway, and DNS
The following is an example using document network address ranges. Replace the IP address, prefix length, gateway, and DNS server with the values provided by your actual network administrator.
sudo nmcli connection modify 'System eth0' \ ipv4.method manual \ ipv4.addresses '192.0.2.20/24' \ ipv4.gateway '192.0.2.1' \ ipv4.dns '192.0.2.53 192.0.2.54'
The new address will apply when the current connection is reactivated. If you are working via SSH, the connection may be interrupted at this moment, so run this on the server console or prepare a way to restore it immediately.
sudo nmcli connection up 'System eth0'
Revert to DHCP automatic settings
To receive the IPv4 address and DNS from DHCP again, change the method to auto and clear the manual values.
sudo nmcli connection modify 'System eth0' \ ipv4.method auto \ ipv4.addresses '' \ ipv4.gateway '' \ ipv4.dns '' sudo nmcli connection up 'System eth0'
If you want to get the address via DHCP but only use the DNS specified by the administrator, set ipv4.ignore-auto-dns yes along with ipv4.dns. To allow automatic DNS again, change the value back to no.
IPv6 settings
Keep automatic settings
In general automatic configuration, ipv6.method auto is used. If you hastily disable IPv6 on an actively operating server just because it is not being used, dependent services may be affected.
sudo nmcli connection modify 'System eth0' ipv6.method auto
Setting a fixed IPv6 address
sudo nmcli connection modify 'System eth0' \ ipv6.method manual \ ipv6.addresses '2001:db8:100::20/64' \ ipv6.gateway '2001:db8:100::1' \ ipv6.dns '2001:db8:100::53'
2001:db8::/32 is also a documentation address, so it cannot be used in actual deployment.
Setting via text menu
If it is difficult to enter command options directly, you can run nmtui and select a connection under Edit a connection. After saving, reactivate it under Activate a connection.
sudo nmtui
Since nmtui also modifies the NetworkManager profile, the results can be re-checked with nmcli connection show.
Checking settings and connection diagnostics
| Items to check | Command |
|---|---|
| Device-specific addresses | ip -brief address |
| Default path and routing | ip route |
| Path to a specific destination | ip route get 192.0.2.1 |
| Profile settings | nmcli connection show 'System eth0' |
| NetworkManager status | systemctl status NetworkManager |
| DNS status | nmcli device show |
If a communication failure occurs, narrow down the scope in the order of gateway on the same subnet, IP duplication, VLAN, firewall, and upstream router. /etc/resolv.conf can be regenerated by NetworkManager, so instead of editing it directly, modify the DNS properties of the connection profile.
Checks before changing the remote server
- Secure an access method independent of SSH, such as a virtual machine console, IPMI, or cloud serial console.
- Make sure the new IP is not in use by another device and that it matches the switch and VLAN settings.
- Ensure that the default gateway is an address reachable from that interface.
- Check that the new IP is allowed in firewalls and access control lists.
- Plan together to change DNS records and monitoring target addresses.
Reference Documents
You can find more detailed instructions on using ip, NetworkManager, nmcli, and nmtui in the Rocky Linux Network Administration Guide.









