RHEL BasedRocky Linux

How To Set Static IP Address on Rocky Linux 10

Set Static IP Address on Rocky Linux 10

Configuring a static IP address on Rocky Linux 10 is essential for servers, workstations, and network devices that require a consistent network identity. Unlike dynamic IP addressing through DHCP, static IP configuration ensures your system maintains the same IP address across reboots, making it ideal for hosting services, database servers, and enterprise infrastructure.

Rocky Linux 10 introduces significant changes to network configuration management, transitioning from the legacy ifcfg files to NetworkManager keyfiles as the default configuration format. This modernization streamlines network management while providing more flexibility and better integration with contemporary Linux networking tools.

This comprehensive guide walks through multiple methods to configure static IP addresses on Rocky Linux 10, including the user-friendly nmtui interface, powerful nmcli command-line tool, and traditional ip command. Whether you’re a system administrator managing production servers or a Linux enthusiast setting up a home lab, this tutorial provides detailed instructions, troubleshooting solutions, and best practices to successfully implement static networking.

Prerequisites

Before configuring a static IP address, ensure you have the following requirements in place:

  • A running Rocky Linux 10 installation with root or sudo privileges
  • Physical console or direct access to the server (avoid SSH to prevent connection loss during reconfiguration)
  • Network information: target static IP address, subnet mask (CIDR notation), gateway address, and DNS server IPs
  • NetworkManager service installed and active (verify with systemctl status NetworkManager)
  • Basic understanding of IP addressing and network fundamentals

Having physical or console access is crucial because changing network settings may temporarily disconnect SSH sessions, potentially locking you out of remote systems.

Understanding Static vs Dynamic IP Configuration

IP addresses can be assigned through two primary methods: static and dynamic configuration.

Static IP addressing involves manually assigning a fixed IP address to a network interface. This configuration persists across system reboots and provides predictable network behavior. Servers hosting websites, databases, email services, or acting as network infrastructure components benefit from static IPs because other systems can consistently reach them at the same address.

Dynamic IP addressing (DHCP) automatically assigns IP addresses from a DHCP server pool. This approach works well for workstations, laptops, and devices that frequently change networks. DHCP simplifies network administration for large numbers of client devices.

Choose static IP configuration when running server services, configuring network appliances, setting up virtual machine hosts, or managing systems requiring remote access with consistent addressing. Dynamic addressing suits desktop workstations and mobile devices where consistent IP assignment isn’t critical.

Rocky Linux 10 Networking Architecture Changes

Rocky Linux 10 represents a significant evolution in network configuration management. The distribution has fully transitioned from the legacy network-scripts package to NetworkManager as the primary network configuration system. This change aligns Rocky Linux with modern Linux networking standards and Red Hat Enterprise Linux 9+ practices.

The most notable change is the shift from ifcfg configuration files to keyfile format. Legacy ifcfg files previously resided in /etc/sysconfig/network-scripts/, while new keyfile configurations are stored in /etc/NetworkManager/system-connections/. Keyfiles use INI-style syntax that’s more human-readable and easier to parse programmatically.

NetworkManager provides several advantages for modern Linux systems:

  • Unified network configuration interface across different connection types
  • Automatic connection state management and recovery
  • D-Bus API for programmatic network control
  • Seamless integration with system services
  • Configuration persistence across reboots without additional scripts

Understanding this architectural shift is essential for effectively managing Rocky Linux 10 networking.

Identifying Your Network Interface

Before configuring a static IP, identify which network interface requires configuration.

Display all network interfaces with the ip command:

ip a

This command shows all network interfaces, their current IP addresses, MAC addresses, and operational status. Common interface naming conventions include enp0s3, eth0, eno1, and ens33, depending on your hardware and system configuration.

Alternatively, use NetworkManager’s nmcli tool:

nmcli device

or the shorter version:

nmcli d

These commands display interface names, types, states, and current connections. Note the exact interface name you want to configure—you’ll need it for subsequent commands.

Method 1: Configure Static IP Using nmtui (Text User Interface)

The nmtui (NetworkManager Text User Interface) provides the most user-friendly approach to network configuration, especially for administrators who prefer graphical-style navigation without leaving the terminal.

Launch nmtui with root privileges:

sudo nmtui

The interface presents three main options. Select “Edit a connection” and press Enter.

The next screen displays all available network connections. Use arrow keys to navigate to your network interface (such as enp0s3 or eth0), then select “Edit” and press Enter.

In the connection editor, navigate to the “IPv4 CONFIGURATION” section. Press Enter on the field that currently shows “Automatic” or “DHCP”. Use arrow keys to select “Manual” from the dropdown menu, then press Enter to confirm.

After selecting Manual mode, new configuration fields appear:

Navigate to the “Addresses” field and select “Add”. Enter your static IP address with CIDR notation. For example, if configuring the IP 192.168.1.100 with a subnet mask of 255.255.255.0 (or /24), enter: 192.168.1.100/24.

Move to the “Gateway” field and enter your network gateway address, typically your router’s IP address (such as 192.168.1.1).

Navigate to the “DNS servers” section and select “Add”. Enter your primary DNS server address (such as 8.8.8.8 for Google DNS). Select “Add” again to input a secondary DNS server (like 8.8.4.4). Important: enter each DNS server on a separate line—nmtui doesn’t support comma-separated values.

If your network uses a DNS search domain, navigate to “Search domains” and add it.

Ensure the “Automatically connect” checkbox is selected to enable automatic connection on system boot.

Navigate to “OK” at the bottom of the editor and press Enter to save changes.

Return to the main menu and select “Activate a connection”. Locate your interface, deactivate it by selecting “Deactivate”, then reactivate it by selecting “Activate”. This applies your new static IP configuration.

Press Escape to exit nmtui.

Method 2: Configure Static IP Using nmcli (Command Line)

The nmcli (NetworkManager Command Line Interface) tool provides powerful network configuration capabilities ideal for automation, scripting, and advanced administration. This method is faster than nmtui and doesn’t require interactive navigation.

First, display current network configuration:

nmcli device show

To view details for a specific interface:

nmcli device show enp0s3

List all network connections:

nmcli connection show

This command displays connection names, UUIDs, types, and associated devices. Note the connection name you want to modify—it’s often the same as the interface name.

Configure static IP using a single comprehensive command:

sudo nmcli con mod enp0s3 ipv4.method manual ipv4.address 192.168.1.151/24 ipv4.gateway 192.168.1.1 ipv4.dns "8.8.8.8 8.8.4.4" connection.autoconnect yes

Replace enp0s3 with your interface name, and adjust IP addresses according to your network configuration.

Alternatively, configure parameters individually for better clarity:

Set the IPv4 address with CIDR notation:

sudo nmcli connection modify enp0s3 ipv4.addresses 192.168.1.151/24

Configure the default gateway:

sudo nmcli connection modify enp0s3 ipv4.gateway 192.168.1.1

Add DNS servers (space or comma-separated for multiple servers):

sudo nmcli connection modify enp0s3 ipv4.dns "8.8.8.8 8.8.4.4"

Set the configuration method to manual (static):

sudo nmcli connection modify enp0s3 ipv4.method manual

Enable automatic connection on boot:

sudo nmcli connection modify enp0s3 connection.autoconnect yes

Understanding each parameter is essential:

  • ipv4.method manual switches from DHCP to static configuration
  • ipv4.addresses specifies the IP address with subnet prefix length
  • ipv4.gateway defines the default gateway for routing traffic
  • ipv4.dns sets DNS nameserver addresses for domain resolution
  • ipv4.dns-search configures DNS search domains (optional)
  • connection.autoconnect yes ensures the connection activates automatically at boot

After modifying the configuration, restart the connection to apply changes:

sudo nmcli con down enp0s3 && sudo nmcli con up enp0s3

The && operator ensures the second command executes only if the first succeeds, minimizing downtime.

Alternatively, restart the entire NetworkManager service:

sudo systemctl restart NetworkManager

This approach applies all pending network configuration changes system-wide.

Method 3: Configure Static IP Using ip Command

The ip command from the iproute2 package provides low-level network interface manipulation. However, changes made with the ip command are not persistent across system reboots—they’re temporary configurations that disappear after restarting the system or NetworkManager service.

This method suits temporary network testing, adding secondary IP addresses, or troubleshooting scenarios where you need immediate network changes without modifying permanent configuration.

Remove an existing IP address from an interface:

sudo ip addr delete 192.168.1.100/24 dev enp0s3

Add a new static IP address:

sudo ip addr add 192.168.1.151/24 dev enp0s3

Add a secondary IP address without removing the existing one:

sudo ip addr add 192.168.1.152/24 dev enp0s3

Configure the default gateway:

sudo ip route add default via 192.168.1.1 dev enp0s3

View the current routing table:

ip route

or use the shorter form:

ip r

Bring a network interface down:

sudo ip link set enp0s3 down

Bring a network interface back up:

sudo ip link set enp0s3 up

The ip command excels at making immediate network changes without restarting interfaces or services. It’s particularly useful for adding multiple IP addresses to a single interface or testing network configurations before making them permanent. However, for production servers requiring persistent static IP configuration, always use NetworkManager methods (nmcli or nmtui) to ensure settings survive reboots.

Configuring DNS Servers

Proper DNS configuration enables your system to resolve domain names to IP addresses. Without functional DNS, you can access servers only by IP address, severely limiting network functionality.

Configure DNS servers using nmcli:

Set a single DNS server:

sudo nmcli con mod enp0s3 ipv4.dns "8.8.8.8"

Configure multiple DNS servers for redundancy:

sudo nmcli con mod enp0s3 ipv4.dns "8.8.8.8 8.8.4.4"

Add a DNS search domain:

sudo nmcli con mod enp0s3 ipv4.dns-search "example.com"

The nmcli command accepts space-separated or comma-separated DNS server lists.

When using nmtui, add each DNS server on a separate line in the interface editor. Nmtui doesn’t accept comma-separated values—each DNS entry requires its own line.

Verify DNS configuration:

nmcli device show enp0s3 | grep DNS

This command filters output to display only DNS-related settings.

Test DNS resolution by attempting to ping a domain name:

ping -c3 google.com

If ping returns IP addresses and receives replies, DNS resolution functions correctly.

Common public DNS servers include:

  • Google DNS: 8.8.8.8, 8.8.4.4
  • Cloudflare DNS: 1.1.1.1, 1.0.0.1
  • OpenDNS: 208.67.222.222, 208.67.220.220

Configure at least two DNS servers for redundancy. If the primary DNS server becomes unavailable, the system automatically queries the secondary server.

Setting Hostname

A properly configured hostname helps identify your server on the network.

Set the system hostname using hostnamectl:

sudo hostnamectl set-hostname myserver.example.com

Verify the hostname change:

hostnamectl

Alternatively, use nmcli to manage hostname:

Check the current hostname:

nmcli general hostname

Change the hostname:

sudo nmcli general hostname newserver.example.com

Hostname changes typically take effect immediately without requiring a reboot. Proper hostname configuration improves system administration, log file clarity, and network service functionality.

Verifying Static IP Configuration

After configuring a static IP address, thoroughly verify the settings to ensure correct implementation.

Display all network interfaces and their IP addresses:

ip address show

or the shorter version:

ip a

This command displays interface names, IP addresses, subnet masks, MAC addresses, and link status.

Show details for a specific interface:

ip addr show dev enp0s3

Use nmcli to view comprehensive interface information:

nmcli device show enp0s3

This output includes IP address, gateway, DNS servers, and connection status.

Verify the interface shows “connected” status and displays your configured static IP address.

Check the routing table to confirm gateway configuration:

ip route

The output should show a default route pointing to your configured gateway.

Examine the NetworkManager keyfile configuration:

sudo cat /etc/NetworkManager/system-connections/enp0s3.nmconnection

Keyfiles are stored in /etc/NetworkManager/system-connections/ with .nmconnection extensions. The file contains all connection parameters in INI format, including IP address, gateway, DNS servers, and autoconnect settings.

These keyfiles should have restrictive permissions (600) for security. NetworkManager automatically sets correct permissions when creating or modifying connections.

Testing Network Connectivity

Systematic connectivity testing confirms your static IP configuration functions correctly.

Test 1: Ping the default gateway

ping -c3 192.168.1.1

Replace 192.168.1.1 with your actual gateway address. Successful replies confirm local network connectivity and correct gateway configuration.

Test 2: Ping another device on the local network

ping -c3 192.168.1.50

This verifies LAN routing functionality and confirms your static IP doesn’t conflict with other network devices.

Test 3: Ping an external IP address

ping -c3 8.8.8.8

Success confirms internet connectivity and proper gateway routing to external networks.

Test 4: Test DNS resolution

ping -c3 google.com

If this command resolves the domain name to an IP address and receives replies, DNS configuration works correctly.

Use the -I flag to test from a specific interface when multiple network connections exist:

ping -I enp0s3 -c3 google.com

Understanding ping output helps diagnose issues:

  • ttl (Time To Live) indicates the number of router hops remaining
  • time shows round-trip latency in milliseconds
  • Packet loss percentage reveals connection reliability

For more detailed network path analysis, use traceroute:

traceroute google.com

or the real-time monitoring tool mtr:

mtr google.com

These tools display each router hop between your system and the destination, helping identify network bottlenecks or routing problems.

Common Troubleshooting Issues

Network Interface Not Activating

If the network interface fails to activate after configuration, check NetworkManager service status:

systemctl status NetworkManager

If the service isn’t running, start it:

sudo systemctl start NetworkManager

Enable it to start automatically at boot:

sudo systemctl enable NetworkManager

Restart NetworkManager to apply changes:

sudo systemctl restart NetworkManager

View detailed connection information:

nmcli con show enp0s3

This command displays all connection parameters, helping identify configuration errors.

Cannot Reach Gateway

Verify the gateway address resides on the same subnet as your static IP. For example, if your IP is 192.168.1.151/24, the gateway must be within the 192.168.1.0/24 range (typically 192.168.1.1).

Check physical network connectivity. Ensure cables are properly connected and switch ports are active.

Verify the routing table:

ip route

The output should show a default route via your gateway address.

IP Conflict with Another Device

IP address conflicts occur when two devices on the same network use identical IP addresses.

Check the ARP cache for duplicate entries:

arp -a

Use arping to detect conflicts:

arping -I enp0s3 192.168.1.151

If multiple MAC addresses respond to the same IP, a conflict exists. Change your static IP to an unused address within your network range.

DNS Resolution Not Working

Verify DNS servers are reachable:

ping -c3 8.8.8.8

Check /etc/resolv.conf for DNS entries:

cat /etc/resolv.conf

NetworkManager automatically manages this file. It should contain nameserver entries matching your configured DNS servers.

Test DNS resolution with dig:

dig google.com

or nslookup:

nslookup google.com

These tools provide detailed DNS query information, helping diagnose resolution failures.

Configuration Not Persisting After Reboot

Ensure automatic connection is enabled:

sudo nmcli con mod enp0s3 connection.autoconnect yes

Verify the keyfile exists in the correct location:

ls -l /etc/NetworkManager/system-connections/

The connection’s keyfile should be present with restrictive permissions (600).

Check NetworkManager is enabled at boot:

systemctl is-enabled NetworkManager

If not enabled, run:

sudo systemctl enable NetworkManager

Lost SSH Connection During Configuration

Network reconfiguration can temporarily disconnect SSH sessions. Always perform initial static IP configuration from physical console or out-of-band management interfaces like IPMI or iLO.

Use the && operator to chain commands, minimizing downtime:

sudo nmcli con down enp0s3 && sudo nmcli con up enp0s3

This ensures the interface comes back up immediately after going down.

If you lose access, connect via physical console or remote management interface to correct configuration errors.

Disabling IPv6 (Optional)

Some environments require IPv6 disabling for security policies or compatibility reasons.

Disable IPv6 at the kernel level using grubby:

sudo grubby --update-kernel ALL --args ipv6.disable=1

Verify the kernel parameter was added:

grubby --info DEFAULT

Reboot the system to apply changes:

sudo reboot

After rebooting, confirm IPv6 is disabled:

ip address show

IPv6 addresses (starting with fe80:: or other IPv6 prefixes) should not appear.

To re-enable IPv6 if needed:

sudo grubby --update-kernel ALL --remove-args ipv6.disable

Then reboot again.

Alternatively, disable IPv6 for specific NetworkManager connections without kernel-level changes:

sudo nmcli con mod enp0s3 ipv6.method disabled

This approach provides granular control over IPv6 per interface.

Congratulations! You have successfully set up a static IP address. Thanks for using this tutorial to set a static IP address on Rocky Linux 10 system. For additional help or useful information, we recommend you check the official Rocky Linux website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button