c

PARAGUAY

TAIWAN

ALBANIA

ARGENTINA

AUSTRALIA

AUSTRIA

AZERBAIJAN

BANGLADESH

BELGIUM

BOSNIA AND HERZEGOVINA

BRAZIL

BULGARIA

CANADA

CHILE

CHINA

COLOMBIA

COSTA RICA

CROATIA

CYPRUS

CZECH

DENMARK

ECUADOR

EGYPT

ESTONIA

FINLAND

FRANCE

GEORGIA

GERMANY

GREECE

GUATEMALA

HUNGARY

ICELAND

IN AFRICA

IN ASIA

IN AUSTRALIA

IN EUROPE

IN NORTH AMERICA

IN SOUTH AMERICA

INDIA

INDONESIA

IRELAND

ISRAEL

ITALY

JAPAN

KAZAKHSTAN

KENYA

KOSOVO

LATVIA

LIBYA

LITHUANIA

LUXEMBOURG

MALAYSIA

MALTA

MEXICO

MOLDOVA

MONTENEGRO

MOROCCO

NETHERLANDS

NEW ZEALAND

NIGERIA

NORWAY

PAKISTAN

PANAMA

PERU

PHILIPPINES

POLAND

PORTUGAL

QATAR

ROMANIA

RUSSIA

SAUDI ARABIA

SERBIA

SINGAPORE

SLOVAKIA

SLOVENIA

SOUTH AFRICA

SOUTH KOREA

SPAIN

SWEDEN

SWITZERLAND

THAILAND

TUNISIA

TURKEY

UAE

UK

UKRAINE

URUGUAY

USA

UZBEKISTAN

VIETNAM

LOGIN

How to Configure a Static IP Address on AlmaLinux 9 Using networkctl

Setting up a static IP address is essential for servers that require consistent network connectivity, such as web servers, databases, or internal applications. In AlmaLinux 9, systemd-networkd provides a modern and efficient way to manage network configurations.

In this guide, we’ll walk you through configuring a static IP address using networkctl and systemd-networkd on AlmaLinux 9.

What You'll Learn

Why Use systemd-networkd for Static IP Configuration?

systemd-networkd is a lightweight, built-in network management service that offers several advantages

  • Faster boot times- Minimal overhead compared to traditional network managers.

  • Simplified configuration- Uses clean, structured configuration files.

  • Better systemd integration- Works seamlessly with other systemd services.

  • Reliable for servers- Ideal for headless and production environments.

If you're managing a server, systemd-networkd ensures stability and control over your network settings.

Step-by-Step Guide to Setting a Static IP on AlmaLinux 9

Step 1: Check systemd-networkd Status

Before configuring a static IP, ensure systemd-networkd and systemd-resolved are running

bash
 
systemctl status systemd-networkd
systemctl status systemd-resolved

                                            

If they’re inactive, start and enable them

bash
 
sudo systemctl start systemd-networkd
sudo systemctl start systemd-resolved
sudo systemctl enable systemd-networkd
sudo systemctl enable systemd-resolved 
                                        

Step 2: Identify Your Network Interface

Find your active network interface name using

bash
 
ip link

                                            

Look for interfaces like eth0, enp0s3, or similar.

Step 3: Create a Static IP Configuration File

Navigate to the network configuration directory

bash
 
cd /etc/systemd/network/

                                            

Create a new .network file (replace enp0s3 with your interface name)

bash
 
sudo nano 20-static-ip.network

                                            

Add the following configuration (adjust IP, gateway, and DNS as needed)

ini
 
[Match]
Name=enp0s3

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


                                        

📌 Key Notes

  • Address=192.168.1.100/24→ Replace with your desired static IP and subnet.

  • Gateway=192.168.1.1→ Use your router’s gateway IP.

  • DNS→ You can use Cloudflare (1.1.1.1) or your preferred DNS servers.

Save and exit (Ctrl+O, Enter, Ctrl+X).

Step 4: Apply the Network Configuration

Restart systemd-networkd to apply changes

bash
 
sudo systemctl restart systemd-networkd 


                                            

Step 5: Verify the Static IP Configuration

Check if the static IP is assigned correctly

bash
 
networkctl status enp0s3


                                            

Or use

bash
 
ip a


                                            

Step 6: Test Network Connectivity

Ensure your server can reach the internet

bash
 
ping google.com


                                            

If DNS resolution fails, restart systemd-resolved

bash
 
sudo systemctl restart systemd-resolved


                                            

Additional Useful Commands

Bring an interface up/down

bash
 
sudo networkctl up enp0s3
sudo networkctl down enp0s3

                                            

Check routing table

bash
 
ip route

                                            

Flush DNS cache (if needed)

Navigate to the network configuration directory

bash
 
sudo resolvectl flush-caches

                                            

Conclusion

Configuring a static IP on AlmaLinux 9 using networkctl is a clean and efficient method, especially for server environments. By leveraging systemd-networkd, you ensure faster boot times and better system integration.

At BytesRack, we specialize in Linux server management, optimizations, and 24/7 support. If you need expert assistance with server configurations, security, or performance tuning, contact us today!

Discover BytesRack Dedicated Server Locations

BytesRack servers are available around the world, providing diverse options for hosting websites. Each region offers unique advantages, making it easier to choose a location that best suits your specific hosting needs.