AlmaLinuxRHEL Based

How To Set Static IP Address on AlmaLinux 10

Set Static IP Address on AlmaLinux 10

Setting up a static IP address on AlmaLinux 10 is essential for enterprise environments where consistent network connectivity and reliable server access are paramount. Unlike dynamic IP addresses assigned through DHCP, static IP configuration ensures your AlmaLinux system maintains the same network identity across reboots and network changes.

AlmaLinux 10, as a community-driven enterprise Linux distribution, provides multiple methods for configuring static IP addresses. This comprehensive guide covers four distinct approaches: command-line tools, text-based interfaces, direct file editing, and graphical user interfaces. Whether you’re a seasoned system administrator or transitioning from other Linux distributions, this article provides the knowledge needed to implement robust network configurations.

Static IP addresses offer numerous advantages in production environments. They eliminate connectivity issues caused by IP address changes, simplify DNS configuration, enable consistent firewall rules, and facilitate remote server management. Understanding these configuration methods ensures optimal network reliability and performance for your AlmaLinux infrastructure.

Prerequisites and System Preparation

Before configuring static IP addresses, verify your system meets the necessary requirements. AlmaLinux 10 supports static IP configuration across all installation variants, from minimal server deployments to full desktop environments.

Essential Prerequisites:

  • Root or sudo administrative privileges
  • Active network connection for initial configuration
  • Basic knowledge of your network infrastructure
  • Text editor familiarity (nano, vim, or gedit)

Begin by gathering critical network information required for static IP configuration. Document your desired static IP address, ensuring it falls within your network’s available range and doesn’t conflict with existing devices. Identify the subnet mask or CIDR notation, typically /24 for most home and small business networks. Note your default gateway IP address, usually your router’s internal interface. Collect primary and secondary DNS server addresses from your network administrator or internet service provider.

Use these commands to assess your current network configuration:

ip addr show
nmcli connection show
nmcli device status

Create backups of existing network configurations before making changes. This precautionary step enables quick restoration if issues arise during configuration:

sudo cp -r /etc/sysconfig/network-scripts/ /etc/sysconfig/network-scripts-backup
sudo nmcli connection export "connection-name" > connection-backup.nmconnection

Understanding AlmaLinux 10 Network Management

AlmaLinux 10 utilizes NetworkManager as the primary network configuration service, providing both command-line and graphical interfaces for network management. This modern approach simplifies network configuration while maintaining compatibility with traditional Red Hat Enterprise Linux networking methods.

NetworkManager manages network connections through profiles, each containing specific configuration parameters for different network scenarios. These profiles persist across system reboots and can be easily modified or replaced as network requirements change.

Network Interface Naming Conventions:

  • Predictable Network Interface Names: Modern naming scheme using hardware-based identifiers
  • enp0s3: Ethernet interface on PCI bus 0, slot 3
  • wlp2s0: Wireless interface on PCI bus 2, slot 0
  • eno1: Onboard Ethernet interface number 1

Configuration files reside in /etc/sysconfig/network-scripts/ directory, maintaining compatibility with legacy Red Hat networking approaches. Each network interface has a corresponding ifcfg-<interface_name> file containing connection parameters.

Understanding the relationship between NetworkManager profiles and configuration files is crucial. NetworkManager reads these files during startup and creates corresponding connection profiles, but direct file modifications require service restarts to take effect.

Method 1: Using nmcli Command Line Tool

The NetworkManager command-line interface (nmcli) provides powerful network configuration capabilities through terminal commands. This method offers precise control and automation possibilities for system administrators managing multiple servers.

Identifying Network Interfaces

Start by identifying available network connections and their current status:

nmcli connection show
nmcli device status

These commands display connection names, device names, connection types, and current states. Note the distinction between connection names (user-defined labels) and device names (hardware identifiers).

For detailed interface information, use:

nmcli device show <interface_name>
ip addr show <interface_name>

Configuring Static IP with nmcli

Configure static IP addressing using a series of nmcli modification commands. Replace <connection_name> with your actual connection name and adjust IP addresses according to your network requirements:

# Set IP address and subnet mask
sudo nmcli connection modify "<connection_name>" ipv4.addresses 192.168.1.100/24

# Configure default gateway
sudo nmcli connection modify "<connection_name>" ipv4.gateway 192.168.1.1

# Set DNS servers
sudo nmcli connection modify "<connection_name>" ipv4.dns "8.8.8.8,8.8.4.4"

# Change from DHCP to manual configuration
sudo nmcli connection modify "<connection_name>" ipv4.method manual

# Disable IPv6 if not required
sudo nmcli connection modify "<connection_name>" ipv6.method ignore

Advanced Configuration Options:

  • Multiple IP addresses: Use comma-separated values for additional IPs
  • Search domains: Configure DNS search domains with ipv4.dns-search
  • Connection autostart: Enable automatic connection with connection.autoconnect yes

Activating and Verifying Configuration

Apply the new configuration by restarting the network connection:

sudo nmcli connection down "<connection_name>"
sudo nmcli connection up "<connection_name>"

Verify the configuration using multiple validation methods:

ip addr show <interface_name>
nmcli connection show "<connection_name>"
ping -c 4 8.8.8.8
nslookup google.com

Monitor network connectivity and performance using continuous ping tests and network diagnostic tools to ensure stable operation.

Method 2: Using nmtui Text-Based Interface

The NetworkManager Text User Interface (nmtui) provides an intuitive, menu-driven approach for network configuration. This method bridges the gap between command-line complexity and graphical interface requirements.

Launching nmtui

Install nmtui if not present on minimal AlmaLinux installations:

sudo dnf install NetworkManager-tui

Launch the text-based interface:

sudo nmtui

Navigate using arrow keys, Tab for field selection, and Enter for menu activation. The interface provides three main options: Edit connections, Activate connections, and Set system hostname.

Configuring Network Settings

Select “Edit a connection” from the main menu. Choose your network interface from the available connections list. If no connections exist, create a new one by selecting “Add” and choosing “Ethernet” as the connection type.

Configuration Steps:

  1. Connection Name: Assign a descriptive name for easy identification
  2. Device: Select the appropriate network interface
  3. IPv4 Configuration: Change from “Automatic” to “Manual”
  4. IP Address: Enter your desired static IP with CIDR notation (e.g., 192.168.1.100/24)
  5. Gateway: Specify your network’s default gateway
  6. DNS Servers: Add primary and secondary DNS server addresses

Navigate through fields using Tab and modify values as needed. The interface validates input format and highlights configuration errors in real-time.

Advanced Settings:

  • MTU: Modify Maximum Transmission Unit if required
  • Routes: Configure custom routing tables
  • 802.1X Security: Enterprise authentication settings

Applying and Testing Changes

Save configuration changes by selecting “OK” and return to the main menu. Activate the new connection profile using “Activate a connection” option or restart NetworkManager service:

sudo systemctl restart NetworkManager

Test connectivity thoroughly:

ping -c 4 <gateway_ip>
ping -c 4 8.8.8.8
dig google.com
traceroute 8.8.8.8

Method 3: Direct Configuration File Editing

Direct configuration file editing provides maximum control over network settings and maintains compatibility with legacy Red Hat networking approaches. This method is particularly useful for automation scripts and environments requiring specific configuration parameters.

Understanding Configuration Files

AlmaLinux network configuration files reside in /etc/sysconfig/network-scripts/ directory. Each network interface has a corresponding ifcfg-<interface_name> file containing connection parameters.

Create backups before editing:

sudo cp /etc/sysconfig/network-scripts/ifcfg-<interface> /etc/sysconfig/network-scripts/ifcfg-<interface>.backup

Common configuration file locations:

  • Interface configs: /etc/sysconfig/network-scripts/ifcfg-*
  • Global network: /etc/sysconfig/network
  • DNS resolution: /etc/resolv.conf

Manual File Configuration

Edit the interface configuration file using your preferred text editor:

sudo nano /etc/sysconfig/network-scripts/ifcfg-<interface_name>

Complete Static IP Configuration Example:

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
NAME="<connection_name>"
UUID=<unique_identifier>
DEVICE=<interface_name>
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=8.8.4.4
ZONE=public

Key Parameter Explanations:

  • BOOTPROTO=static: Enables static IP configuration
  • ONBOOT=yes: Activates interface during system startup
  • DEFROUTE=yes: Uses this interface for default routing
  • IPV6INIT=no: Disables IPv6 if not required
  • ZONE=public: Assigns firewall zone for security policies

Service Restart and Validation

Apply configuration changes by restarting network services:

# Restart NetworkManager (recommended)
sudo systemctl restart NetworkManager

# Alternative: Legacy network service
sudo systemctl restart network

# Interface-specific restart
sudo ifdown <interface_name> && sudo ifup <interface_name>

Validate configuration thoroughly:

systemctl status NetworkManager
ip route show
cat /etc/resolv.conf
netstat -rn

Method 4: GUI Configuration (GNOME Settings)

GNOME desktop environment provides an intuitive graphical interface for network configuration, ideal for desktop users and administrators preferring visual configuration methods.

Accessing Network Settings

Open GNOME Control Center through Activities menu or execute:

gnome-control-center network

The Network panel displays available network connections with their current status, connection types, and basic configuration information.

Navigation Steps:

  1. Select “Settings” from Activities menu
  2. Choose “Network” from the sidebar
  3. Identify your active network connection
  4. Click the gear icon for configuration options

Static IP Configuration via GUI

Click the gear icon next to your active network connection to access detailed settings. Navigate to the “IPv4” tab for IP configuration options.

Configuration Process:

  1. Method Selection: Change from “Automatic (DHCP)” to “Manual”
  2. IP Address: Enter your desired static IP address
  3. Netmask: Specify subnet mask (e.g., 255.255.255.0)
  4. Gateway: Configure default gateway address
  5. DNS Servers: Add primary and secondary DNS servers

Advanced Options:

  • Routes: Custom routing table entries
  • Search Domains: DNS search domain configuration
  • Proxy Settings: HTTP/HTTPS proxy configuration

Applying Changes

Click “Apply” to save configuration changes. The interface automatically restarts the network connection and applies new settings. Monitor the connection status indicator for successful configuration.

Immediate Verification:

  • Connection status changes to “Connected” with static IP
  • Network icon in system tray updates connection status
  • Open terminal and verify with ip addr show

Advanced Configuration Options

IPv6 Configuration

Configure IPv6 static addressing alongside IPv4 for dual-stack network environments:

# Enable IPv6 with static addressing
sudo nmcli connection modify "<connection_name>" ipv6.method manual
sudo nmcli connection modify "<connection_name>" ipv6.addresses 2001:db8::100/64
sudo nmcli connection modify "<connection_name>" ipv6.gateway 2001:db8::1
sudo nmcli connection modify "<connection_name>" ipv6.dns "2001:4860:4860::8888"

IPv6 Configuration File Parameters:

IPV6INIT=yes
IPV6_AUTOCONF=no
IPV6ADDR=2001:db8::100/64
IPV6_DEFAULTGW=2001:db8::1

Multiple IP Addresses

Configure secondary IP addresses for virtual hosting, service segregation, or network redundancy:

# Add secondary IP address
sudo nmcli connection modify "<connection_name>" +ipv4.addresses 192.168.1.101/24

# Configuration file method
echo "IPADDR1=192.168.1.101" >> /etc/sysconfig/network-scripts/ifcfg-<interface>
echo "NETMASK1=255.255.255.0" >> /etc/sysconfig/network-scripts/ifcfg-<interface>

Network Bonding and VLANs

Basic Network Bonding Setup:

# Create bonding interface
sudo nmcli connection add type bond con-name bond0 ifname bond0 mode active-backup
sudo nmcli connection add type ethernet slave-type bond con-name bond0-slave1 ifname <interface1> master bond0
sudo nmcli connection add type ethernet slave-type bond con-name bond0-slave2 ifname <interface2> master bond0

VLAN Configuration:

# Create VLAN interface
sudo nmcli connection add type vlan con-name vlan100 ifname <interface>.100 dev <interface> id 100
sudo nmcli connection modify vlan100 ipv4.method manual ipv4.addresses 192.168.100.10/24

Troubleshooting Common Issues

Configuration Not Persisting

NetworkManager vs. Network Service Conflicts:
Ensure only one network management service is active:

sudo systemctl disable network
sudo systemctl enable NetworkManager
sudo systemctl start NetworkManager

File Permission Issues:
Verify configuration file permissions and ownership:

sudo chmod 644 /etc/sysconfig/network-scripts/ifcfg-*
sudo chown root:root /etc/sysconfig/network-scripts/ifcfg-*

Syntax Errors:
Validate configuration file syntax:

sudo nmcli connection reload
sudo nmcli connection validate /etc/sysconfig/network-scripts/ifcfg-<interface>

Connectivity Problems

Gateway Reachability Testing:

# Test gateway connectivity
ping -c 4 <gateway_ip>
traceroute <gateway_ip>
arp -a | grep <gateway_ip>

DNS Resolution Troubleshooting:

# Check DNS configuration
cat /etc/resolv.conf
nslookup google.com
dig @8.8.8.8 google.com
systemd-resolve --status

Firewall and Routing Issues:

# Check firewall status
sudo firewall-cmd --list-all
sudo iptables -L

# Examine routing table
ip route show
netstat -rn

Performance and Compatibility Issues

Network Interface Driver Issues:

# Check driver information
ethtool -i <interface_name>
dmesg | grep -i network
lspci | grep -i ethernet

MTU Size Optimization:

# Test optimal MTU size
ping -M do -s 1472 8.8.8.8
sudo nmcli connection modify "<connection_name>" ethernet.mtu 1500

Security Best Practices

Implement robust security measures when configuring static IP addresses. Document IP address assignments to prevent conflicts and maintain network inventory accuracy. Configure firewall rules specific to static IP addresses, ensuring only necessary services are accessible.

Firewall Configuration:

# Configure zone-based firewall rules
sudo firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="192.168.1.0/24" accept'
sudo firewall-cmd --reload

Access Control Measures:

  • Implement SSH key-based authentication
  • Configure fail2ban for intrusion prevention
  • Enable audit logging for network configuration changes
  • Regular security updates and vulnerability assessments

Network Monitoring:

# Monitor network connections
ss -tuln
netstat -tuln
sudo tcpdump -i <interface> -n

Verification and Testing Procedures

Implement comprehensive testing procedures to validate static IP configuration. Create automated scripts for routine verification and maintain documentation for troubleshooting purposes.

Connectivity Testing Script:

#!/bin/bash
INTERFACE="<interface_name>"
GATEWAY="<gateway_ip>"
DNS_SERVER="8.8.8.8"

echo "Testing network connectivity..."
ping -c 4 $GATEWAY && echo "Gateway reachable" || echo "Gateway unreachable"
ping -c 4 $DNS_SERVER && echo "DNS reachable" || echo "DNS unreachable"
nslookup google.com && echo "DNS resolution working" || echo "DNS resolution failed"

Performance Verification:

# Bandwidth testing
iperf3 -c <test_server>
speedtest-cli

# Latency monitoring
ping -c 100 8.8.8.8 | tail -1

Congratulations! You have successfully set up a static IP address. Thanks for using this tutorial to set a static IP address on AlmaLinux OS 10 system. For additional help or useful information, we recommend you check the official CentOS Stream 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