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.

More in This Category
How to List Installed Packages on Rocky Linux

How to List Installed Packages on Rocky Linux

Use DNF and RPM to list, search, count, and inspect installed packages on Rocky Linux and identify which package owns a file.

How to Manage firewalld on Rocky Linux: Zones, Services, and Ports

How to Manage firewalld on Rocky Linux: Zones, Services, and Ports

Learn how to manage firewalld on Rocky Linux with firewall-cmd, including active zones, services, custom ports, runtime and permanent rules, rich rules, and NetworkManager integration. The guide emphasizes a safe workflow for remote SSH servers.

How to Install PostgreSQL on Rocky Linux

How to Install PostgreSQL on Rocky Linux

Install PostgreSQL on Rocky Linux, initialize the database cluster, enable the service, create a database and user, and review network and authentication settings.

How to Configure SELinux Modes on Rocky Linux

How to Configure SELinux Modes on Rocky Linux

Check and change SELinux enforcing, permissive, and disabled modes on Rocky Linux, understand temporary and persistent changes, and troubleshoot denials safely.

How to Configure Root SSH Login on Rocky Linux Safely

How to Configure Root SSH Login on Rocky Linux Safely

Review how root SSH login is controlled on Rocky Linux, why direct root access is risky, and how to change and verify sshd settings without losing remote access.

How to Change the System Language and Locale on Rocky Linux

How to Change the System Language and Locale on Rocky Linux

Learn how to check and change the system-wide language and locale on Rocky Linux with localectl and glibc language packs. This guide also explains session-only changes, LANG and LC_* precedence, and troubleshooting for broken Korean characters.

How to Change the Hostname on Rocky Linux

How to Change the Hostname on Rocky Linux

Learn how to change a Rocky Linux hostname with hostnamectl, verify the persistent setting, and check name resolution and services afterward.

How to Configure a Static IP Address on Rocky Linux

How to Configure a Static IP Address on Rocky Linux

Configure and verify a static IPv4 address on Rocky Linux with NetworkManager, including the gateway, DNS servers, connection profile, and safe remote-change checks.

How to Use DNF on Rocky Linux: Packages, Repositories, and Updates

How to Use DNF on Rocky Linux: Packages, Repositories, and Updates

Use DNF on Rocky Linux to search, install, remove, update, and inspect packages and repositories while keeping package-management changes controlled.

How to Install a GUI and Remote Desktop on Rocky Linux

How to Install a GUI and Remote Desktop on Rocky Linux

Install a graphical desktop on Rocky Linux, select the graphical boot target, configure remote access, and review firewall and security considerations.