Linux Tutorials

Configure Static IP Address on RHEL 10 / Rocky Linux 10

Servers and workstations that provide network services need predictable, fixed IP addresses. Static IP configuration ensures your machine is always reachable at the same address – critical for DNS servers, web servers, databases, and any system other machines depend on. Without a static IP, DHCP can reassign your address after a lease expires, breaking connectivity for every service and client that relied on the old address.

Original content from computingforgeeks.com - post 55

This guide covers every method to configure a static IP address on RHEL 10, Rocky Linux 10, and AlmaLinux 10. We walk through nmcli (command line), nmtui (text UI), connection profile files, DNS configuration, multiple IPs on a single interface, and systemd-networkd for minimal server installs without NetworkManager.

Prerequisites

  • A system running RHEL 10, Rocky Linux 10, or AlmaLinux 10
  • Root or sudo access
  • Knowledge of your network details: IP address, subnet mask (prefix length), gateway, and DNS servers
  • Physical or SSH access to the server (if changing IP remotely over SSH, have console access as backup)

Step 1: Identify Your Network Interface

Before configuring a static IP, identify the network interface name. Modern RHEL-based systems use predictable names like ens18, enp0s3, or eth0 depending on the hardware and hypervisor.

List all network interfaces with ip addr:

ip addr show

The output shows each interface with its current IP assignment. Look for the interface that has your active network connection – it will have an inet address and state UP:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    inet 127.0.0.1/8 scope host lo
2: ens18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP
    inet 192.168.1.50/24 brd 192.168.1.255 scope global dynamic ens18

You can also use nmcli to list devices and their connection status:

nmcli device status

This shows each device, its type, state, and the associated connection profile name:

DEVICE  TYPE      STATE                   CONNECTION
ens18   ethernet  connected               ens18
lo      loopback  connected (externally)  lo

Note the interface name (e.g., ens18) and the connection name. You will use these in the next steps.

The nmcli command is the recommended way to configure networking on RHEL 10 and its derivatives. It modifies the connection profile and applies changes immediately or on reconnect. This method works for both desktop and server installations that use NetworkManager.

First, check your existing connection profile name:

nmcli connection show

The output lists all connection profiles. The NAME column is what you reference in subsequent commands:

NAME    UUID                                  TYPE      DEVICE
ens18   a1b2c3d4-5678-90ab-cdef-1234567890ab  ethernet  ens18

Set the connection to use a static IP instead of DHCP. Replace ens18 with your connection name and adjust the IP, gateway, and DNS to match your network:

sudo nmcli connection modify ens18 ipv4.addresses 192.168.1.100/24
sudo nmcli connection modify ens18 ipv4.gateway 192.168.1.1
sudo nmcli connection modify ens18 ipv4.dns "8.8.8.8 8.8.4.4"
sudo nmcli connection modify ens18 ipv4.method manual

The ipv4.method manual setting tells NetworkManager to use the static address instead of requesting one from DHCP. Apply the changes by reactivating the connection:

sudo nmcli connection up ens18

The connection reactivates with the new static IP. If you are connected via SSH on the old IP, your session will drop – reconnect using the new IP address.

You can also set all parameters in a single command:

sudo nmcli connection modify ens18 ipv4.addresses 192.168.1.100/24 ipv4.gateway 192.168.1.1 ipv4.dns "8.8.8.8 8.8.4.4" ipv4.method manual

Verify the configuration took effect:

nmcli connection show ens18 | grep ipv4

You should see your static IP, gateway, DNS, and method set to manual:

ipv4.method:                            manual
ipv4.dns:                               8.8.8.8,8.8.4.4
ipv4.addresses:                         192.168.1.100/24
ipv4.gateway:                           192.168.1.1

Step 3: Configure Static IP with nmtui (Text User Interface)

If you prefer a menu-driven interface, nmtui provides a text-based UI for NetworkManager. It is preinstalled on RHEL 10 / Rocky Linux 10 / AlmaLinux 10 and works over SSH or console.

Launch nmtui:

sudo nmtui

Follow these steps in the TUI:

  1. Select Edit a connection and press Enter
  2. Select your network interface (e.g., ens18) and press Enter
  3. Under IPv4 CONFIGURATION, change <Automatic> to <Manual>
  4. Select Show next to IPv4 Configuration to expand the fields
  5. Add your static IP address with prefix (e.g., 192.168.1.100/24)
  6. Set the Gateway (e.g., 192.168.1.1)
  7. Add DNS servers (e.g., 8.8.8.8)
  8. Select OK to save

After saving, go back to the main menu and select Activate a connection. Deactivate then reactivate your interface to apply the changes. Alternatively, restart the connection from the command line:

sudo nmcli connection down ens18 && sudo nmcli connection up ens18

Step 4: Configure Static IP with Connection Profile Files

RHEL 10 and its derivatives store NetworkManager connection profiles as keyfile-format files in /etc/NetworkManager/system-connections/. The old ifcfg format under /etc/sysconfig/network-scripts/ is no longer supported. You can edit these files directly for static IP configuration.

List existing connection profiles:

ls /etc/NetworkManager/system-connections/

You should see a .nmconnection file for each configured interface:

ens18.nmconnection

Open the connection file for editing:

sudo vi /etc/NetworkManager/system-connections/ens18.nmconnection

Update the [ipv4] section with your static IP configuration:

[connection]
id=ens18
type=ethernet
interface-name=ens18
autoconnect=true

[ipv4]
method=manual
address1=192.168.1.100/24,192.168.1.1
dns=8.8.8.8;8.8.4.4;

[ipv6]
method=auto

The address1 field uses the format IP/PREFIX,GATEWAY. Multiple DNS servers are separated by semicolons with a trailing semicolon. After saving the file, reload NetworkManager to pick up the changes:

sudo nmcli connection reload
sudo nmcli connection up ens18

The connection file must have restrictive permissions (600) owned by root. NetworkManager sets this automatically when it creates the file, but if you create one manually, set permissions explicitly:

sudo chmod 600 /etc/NetworkManager/system-connections/ens18.nmconnection
sudo chown root:root /etc/NetworkManager/system-connections/ens18.nmconnection

Step 5: Configure DNS Servers

DNS is typically set during static IP configuration (as shown in Steps 2-4), but you may need to change DNS servers independently or add search domains. On systems running NetworkManager, never edit /etc/resolv.conf directly – NetworkManager overwrites it. Use nmcli instead.

Set DNS servers for a connection:

sudo nmcli connection modify ens18 ipv4.dns "8.8.8.8 1.1.1.1"

Add a DNS search domain (useful in corporate environments where you want to resolve short hostnames):

sudo nmcli connection modify ens18 ipv4.dns-search "example.com lab.local"

Apply the DNS changes:

sudo nmcli connection up ens18

Verify the DNS servers are active by checking /etc/resolv.conf:

cat /etc/resolv.conf

The file should show the DNS servers and search domain you configured:

search example.com lab.local
nameserver 8.8.8.8
nameserver 1.1.1.1

To prevent NetworkManager from managing /etc/resolv.conf (rarely needed, but useful in some setups), you can set dns=none in /etc/NetworkManager/NetworkManager.conf under the [main] section. After that change, restart NetworkManager with sudo systemctl restart NetworkManager.

Step 6: Configure Multiple IP Addresses on One Interface

A single network interface can hold multiple IP addresses. This is common for servers hosting multiple websites, services that bind to different IPs, or migration scenarios where you need both old and new addresses active simultaneously.

Add a second IP address to an existing connection using nmcli with the + prefix:

sudo nmcli connection modify ens18 +ipv4.addresses 192.168.1.101/24

The + prefix appends the address instead of replacing the existing one. Apply the change:

sudo nmcli connection up ens18

Verify both addresses are assigned to the interface:

ip addr show ens18

You should see both IP addresses listed under the interface:

2: ens18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP
    inet 192.168.1.100/24 brd 192.168.1.255 scope global ens18
    inet 192.168.1.101/24 brd 192.168.1.255 scope global secondary ens18

To remove a secondary IP address, use the - prefix:

sudo nmcli connection modify ens18 -ipv4.addresses 192.168.1.101/24
sudo nmcli connection up ens18

In the connection profile file, multiple addresses use numbered keys: address1, address2, etc. The first address includes the gateway; additional addresses do not:

[ipv4]
method=manual
address1=192.168.1.100/24,192.168.1.1
address2=192.168.1.101/24

Step 7: Configure Static IP on Server Without NetworkManager (systemd-networkd)

Minimal server installations or container hosts may run without NetworkManager. In these cases, systemd-networkd handles network configuration. This is also the default on systems built from minimal kickstart installs that explicitly exclude NetworkManager. Check the RHEL 10 networking documentation for details on supported configurations.

First, confirm systemd-networkd is available and enable it:

sudo systemctl enable --now systemd-networkd
sudo systemctl enable --now systemd-resolved

Create a network configuration file for your interface. The filename must end in .network and files are processed in alphabetical order:

sudo vi /etc/systemd/network/10-static.network

Add the following configuration, adjusting the interface name and network details for your environment:

[Match]
Name=ens18

[Network]
Address=192.168.1.100/24
Gateway=192.168.1.1
DNS=8.8.8.8
DNS=8.8.4.4

[Link]
RequiredForOnline=routable

The [Match] section ties this config to the correct interface. The [Network] section defines the static IP, gateway, and DNS. The [Link] section tells systemd-networkd-wait-online what “online” means for this interface.

If NetworkManager is still running, stop and disable it to avoid conflicts:

sudo systemctl stop NetworkManager
sudo systemctl disable NetworkManager

Restart systemd-networkd to apply the configuration:

sudo systemctl restart systemd-networkd

Check the network status:

networkctl status ens18

The output should show the interface as routable with your static IP assigned:

  Type: ether
 State: routable (configured)
   Address: 192.168.1.100
   Gateway: 192.168.1.1
       DNS: 8.8.8.8
            8.8.4.4

For DNS resolution with systemd-resolved, link /etc/resolv.conf to the resolved stub:

sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

Step 8: Verify Network Connectivity

After configuring a static IP using any method above, verify that the configuration is correct and the system has network connectivity.

Check the assigned IP address on the interface:

ip addr show ens18

Confirm your static IP appears with the correct prefix length:

2: ens18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP
    inet 192.168.1.100/24 brd 192.168.1.255 scope global ens18

Check the default route to confirm your gateway is set:

ip route show default

The output should show your gateway as the default route:

default via 192.168.1.1 dev ens18 proto static metric 100

Test connectivity to your gateway:

ping -c 3 192.168.1.1

All three packets should return successfully with no packet loss:

PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.5 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.4 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.4 ms

--- 192.168.1.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss

Test internet connectivity and DNS resolution:

ping -c 3 google.com

If this works, both your internet connectivity and DNS resolution are functioning correctly. If the ping to the IP works but DNS resolution fails, check your DNS configuration in Step 5.

Verify DNS servers are configured:

cat /etc/resolv.conf

If you need to set the hostname on your server alongside the static IP configuration, use hostnamectl:

sudo hostnamectl set-hostname server01.example.com

For servers exposed to the network, configure firewalld on Rocky Linux 10 / RHEL 10 to control which ports and services are accessible on your new static IP.

Conclusion

You have configured a static IP address on RHEL 10, Rocky Linux 10, or AlmaLinux 10 using nmcli, nmtui, connection profile files, and systemd-networkd. The nmcli method is the most straightforward for most environments, while systemd-networkd serves minimal installs without NetworkManager. For production servers, also configure static IP on Rocky Linux 9 systems still in your fleet, set up monitoring for network interface status, and maintain documentation of your IP address assignments to avoid conflicts.

Related Articles

AlmaLinux Install MicroK8s Kubernetes on Rocky Linux 9 / AlmaLinux 9 AlmaLinux Fix ifup Command Not Found on RHEL 10 / Rocky Linux 10 / AlmaLinux 10 AlmaLinux Install Android Studio on Rocky Linux 9|AlmaLinux 9|Oracle Linux 9 AlmaLinux Install GitLab CE on Rocky Linux 10 / AlmaLinux 10 with SSL

5 thoughts on “Configure Static IP Address on RHEL 10 / Rocky Linux 10”

Leave a Comment

Press ESC to close