MaruOpsInfrastructure and AI notes

About (Korean)Contact (Korean)

Set a Static IP on Rocky Linux 9 with nmtui and nmcli

Cisco Ethernet Switch with Optical Ports

Reference photo · Cisco Ethernet Switch with Optical Ports · Photo: Pmauduit / Source / CC BY-SA 3.0 · Resized for listings; illustrative photo, not the tested environment

A server’s stable address depends on the subnet, default gateway, DNS and DHCP allocation range as well as the chosen IP. Record those values before editing the NetworkManager profile. This avoids rebuilding an SSH connection plan after a reboot changes the VM’s address.

This guide uses NetworkManager on Rocky Linux 9.x. Use nmtui for an interactive screen or nmcli to record and repeat the commands. Both tools manage the same connection profiles. The RHEL 9 Ethernet configuration guide documents both approaches.

Linux operation articles seen together · Rocky 9 Fixed IP · Ubuntu 24.04 Netplan · Ubuntu 26.04·nmtui·systemd service·log·LVM root extension·general partition root Expand

On this page

1. Check the connected network before deciding on the IP.

itemExamples from this articleWhere to check in the real world
network deviceens33ip -br link device name
Fixed address/prefix192.168.50.20/24Addresses and subnets assigned by administrator
default gateway192.168.50.1IP route, router, and VMware settings for the current normal connection
DNS server192.168.50.1Verify that DNS is provided at that address
connection profileWired connection 1NAME·UUID in nmcli connection show

The above address is for illustration purposes only. /24 means the same network mask as 255.255.255.0 in IPv4. In this example, the gateway is also at the same 192.168.50.0/24. Just because your router is a gateway, you shouldn’t assume that it also provides DNS.

VMware Workstation’s NAT network, bridge network, and host-only network are different connections. If it is NAT, check the subnet, NAT gateway, and DHCP range of the VMnet in the Virtual Network Editor. Do not pass the Windows host’s VMnet address as the guest’s gateway. Bridges follow the address policy of the actual LAN, and Host-only may not have an outgoing route to the Internet.

Manual addresses are assigned an available address outside the DHCP pool. It is also easy to manage by continuously receiving the same address through DHCP reservation. Reservation is when the DHCP server assigns an address based on MAC address, etc., and static IP, which is covered here, stores the value directly in the guest OS. Also check that the IPs and MACs of the cloned VMs do not overlap.

cat /etc/os-release
ip -br link
ip -4 -br address
ip -4 route
nmcli device status
nmcli -f NAME,UUID,TYPE,DEVICE connection show
nmcli --version

ens33 is the device name and Wired connection 1 is the name of the settings bundle. They don’t have to be the same. Profiles with overlapping names can be distinguished by specifying a UUID. The two values ​​in subsequent commands are swapped to match the actual output.

2. Save the original profile and prepare the console

NIC='ens33'
PROFILE='Wired connection 1'
BACKUP_PROFILE='before-static-ens33'

nmcli connection show "$PROFILE"
sudo nmcli connection clone "$PROFILE" "$BACKUP_PROFILE"
sudo nmcli connection modify "$BACKUP_PROFILE" connection.autoconnect no

Choose a backup profile name that does not overlap with an existing name. The reason for turning off autoconnect is so that the backup and new settings don’t compete for the same device on the next boot. Because your profile may contain sensitive information, we do not post the entire output to a public bulletin board.

IP changes may cause your current SSH connection to be lost. Proceed with the VMware console or remote console open. Below nmtui and nmcli are two methods for the same purpose. There is no need to set it up one way and then follow the other way.

3. Enter the static IP in nmtui

sudo dnf install -y NetworkManager-tui
sudo nmtui
  1. Edit a connection / Edit connection In , select the profile you checked earlier and enter Edit.
  2. Change IPv4 CONFIGURATION to Manual / Manual and expand Show.
  3. Enter 192.168.50.20/24 in Addresses, 192.168.50.1 in Gateway, and the actual DNS address in DNS servers. Make sure there are no old IPv4 addresses left behind that you don’t need.
  4. If the NIC is responsible for external communication, do not select Never use this network for default route. If it is a separate internal network NIC, a configuration that does not create a default route may be correct.
  5. Confirm and save Aautomatically connect. IPv6 maintains existing policies and does not disable en masse due to IPv4 settings.
  6. Re-enable the connection in the console and check the actual address and route.

Tab is used to move items, arrow keys are used to select, and Space is used to change checkboxes. Saving is a profile change, but reflecting it to already running connections is a separate process. Currently, in SSH, if you run down first, you may lose the opportunity to type the next up command. Raise the profile again in the console as shown below.

sudo nmcli connection up "$PROFILE" ifname "$NIC"

4. Specify the same value with nmcli

The following is an example of console operation, , which replaces nmtui. Uses the specified DNS rather than shuffling IPv4’s auto-assigned DNS. DNS received from IPv6 follows existing IPv6 policies. If you previously operated a separate static route, also review ipv4.routes first. The command below does not clear all existing routes.

sudo nmcli connection modify "$PROFILE" \
  ipv4.method manual \
  ipv4.addresses '192.168.50.20/24' \
  ipv4.gateway '192.168.50.1' \
  ipv4.dns '192.168.50.1' \
  ipv4.ignore-auto-dns yes \
  ipv4.never-default no \
  connection.autoconnect yes

sudo nmcli connection up "$PROFILE" ifname "$NIC"

Edit profile changes saved settings and activates connection up on your device. You do not need to restart the entire NetworkManager every time you change the settings. The meaning of the properties can be found in the nmcli official manual.

To use checkpoints in remote tasks

Before changing the values, you can run modification and activation together inside a checkpoint. Use the installed nmcli help to verify support for device checkpoint. The following is an alternative to the earlier modify and up commands.

nmcli device help
sudo nmcli device checkpoint --timeout 120 "$NIC" -- bash -c '
  nmcli connection modify "$1" \
    ipv4.method manual \
    ipv4.addresses "192.168.50.20/24" \
    ipv4.gateway "192.168.50.1" \
    ipv4.dns "192.168.50.1" \
    ipv4.ignore-auto-dns yes \
    ipv4.never-default no \
    connection.autoconnect yes &&
  nmcli connection up "$1" ifname "$2"
' _ "$PROFILE" "$NIC"

Confirm success in the original terminal to keep the changes. Test access to the new address from a separate window, then confirm from the open console. Without confirmation, NetworkManager attempts recovery after the timeout. See the NetworkManager checkpoint example. Keep console access and a backup connection profile available even when using a checkpoint.

5. Check address, path, and DNS separately

ip -4 address show dev "$NIC"
ip -4 route
ip route get 1.1.1.1
nmcli -f GENERAL,IP4 device show "$NIC"
ping -c 3 192.168.50.1
getent ahostsv4 example.com
curl --connect-timeout 5 --max-time 10 -I https://example.com

ip route get shows which path to choose and does not guarantee that the packet will arrive. Gateway communication, name lookup, and HTTPS response are each checked. In a network that blocks ICMP, a ping failure alone does not determine that the entire connection is lost. If you need DNS for internal services, check your internal name lookup needs before replacing with public DNS.

Revert when changes are made incorrectly

Raising a backup profile from the console will allow you to reuse the original settings you saved. This example will continue to turn off autoconnect for backups, and also temporarily turn off autoconnect for profiles that you have changed, so that incorrect values ​​are not selected again on reboot.

sudo nmcli connection modify "$PROFILE" connection.autoconnect no
sudo nmcli connection up "$BACKUP_PROFILE" ifname "$NIC"

Once you have accepted the backup settings as the final configuration, confirm and set connection.autoconnect yes for that backup profile. If you choose to go the route of reverting the original profile to DHCP, empty the Address, Gateway, and Manual DNS as shown below. If there are separate routes, they must also be reviewed according to the DHCP configuration.

sudo nmcli connection modify "$PROFILE" \
  ipv4.method auto \
  ipv4.addresses '' \
  ipv4.gateway '' \
  ipv4.dns '' \
  ipv4.ignore-auto-dns no \
  connection.autoconnect yes
sudo nmcli connection up "$PROFILE" ifname "$NIC"

You can complete the setup task by checking whether the address is maintained after reboot after change and that it does not overlap with other VMs. In Ubuntu Server, the same NIC can be managed by Netplan, so we start by checking the management entity of Ubuntu 24.04 Netplan.

Verification Scope · 2026-10-18: Confirmed offline creation/modification of profiles and DHCP switching in NetworkManager 1.54.3 on Rocky Linux 9.8. Real address enforcement and backup profile recovery were run on NetworkManager 1.46 on an Ubuntu 24.04.5 VM with an isolated secondary NIC. The nmtui input sequence was checked against the RHEL 9 official documentation and is not the result of Rocky VM booting and applying it directly on your VMware network.

Download the network·systemd example file·Netplan YAML, bundled scripts that read service·environment files and storage structures. Change the address and device name to match the actual environment. It does not include scripts to auto-expand disks.