When managing Linux servers, having a static IP address is crucial for consistent connectivity, especially in production environments. In AlmaLinux 9, systemd-networkd is the recommended way to manage network configurations — offering simplicity, speed, and reliability.
In this tutorial, we’ll walk you through how to assign a static IP address using networkctl and systemd-networkd.
Why Use systemd-networkd for Static IP Configuration?
systemd-networkd is a native systemd service that handles basic network configuration. It’s lightweight and ideal for headless or server environments.
Key benefits include:
- Faster boot times
- Cleaner configuration management
- Better integration with systemd services
Step-by-Step: Configuring a Static IP on AlmaLinux 9
Step 1: Check Network Service Status
Before making changes, verify that the required services are active:
systemctl status systemd-networkd
systemctl status systemd-resolved
If they are inactive or failed, start them with:
systemctl start systemd-networkd
systemctl start systemd-resolved
And enable them to persist after reboot:
systemctl enable systemd-networkd
systemctl enable systemd-resolved
Step 2: Identify Your Network Interface
Use the following command to find your network interface name
ip link
or
ip a
Look for interfaces like enp0s3, eth0, or similar.
Step 3: Create a Static Network Configuration File
Navigate to the configuration directory:
cd /etc/systemd/network/
Now, create a new configuration file. Replace enoxx with your actual interface name:
nano 20-static.network
Add the following content to define your static IP:
[Match]
Name=enoxx
[Network]
Address=192.168.1.x/x
Gateway=192.168.1.1
DNS=8.8.8.8
DNS=8.8.4.4
Note:
- Replace 192.168.1.x/x with your desired static IP address and subnet (e.g., 192.168.1.100/24).
- Replace 192.168.1.1 with your network’s gateway IP.
- You can substitute Google DNS with your preferred DNS servers.
Step 4: Restart the Network Service
Apply the changes by restarting the network daemon
systemctl restart systemd-networkd
Step 5: Verify Your Network Configuration
Check if the static IP is successfully applied using:
networkctl status
or for a specific interface:
networkctl status enoxx
Step 6: Test Network Connectivity
Ensure the server can connect to the internet:
ping 8.8.8.8
Additional Commands
Bring an interface up manually:
networkctl up enoxx
To bring it down:
networkctl down enoxx
Conclusion
Configuring a static IP on AlmaLinux 9 using networkctl offers greater control, predictability, and performance. Whether you’re setting up production servers or cloud instances, understanding systemd-networkd ensures your network stays stable and reliable.
At ServerAdminz, we handle complex Linux configurations and infrastructure tuning around the clock. If you need assistance setting up, optimizing, or managing your Linux servers, our experts are just a click away.
Need Help with Linux Server Configuration?
Let us do the heavy lifting! Contact ServerAdminz for expert server management and 24/7 Linux support.