How to Set a Static IP Address on Arch Linux

This article provides a step-by-step guide on how to set a static IP address on Arch Linux.

In the world of Linux, Arch is known for its simplicity, minimalism, and full user control. One area where this control is evident is in network configuration. While many distributions provide graphical tools for setting IP addresses, Arch relies on command-line tools and configuration files, giving users more flexibility and transparency.

In this guide, we’ll cover how to set a static IP address on Arch Linux using different methods, including:

  • Using systemd-networkd
  • Using NetworkManager
  • Using netctl

By the end of this article, you’ll have a solid understanding of how to assign a static IP address manually on Arch, regardless of which network management method you prefer.


Why Use a Static IP?

Before diving into the technical steps, it’s important to understand why you might want a static IP address:

  • Servers: If you’re running services like SSH, a web server, or an FTP server, having a consistent IP address ensures that clients can always reach your machine.
  • Port Forwarding: For home networks, setting up port forwarding on your router works best when your device always has the same internal IP.
  • Network Stability: DHCP might reassign different IPs after a lease expires, which can cause issues in scripts or network configurations.

Step 1: Determine Your Network Interface Name

First, you need to know which network interface you want to configure.

Open a terminal and run:

ip link

You’ll see output like:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000

In this example, the interface name is enp0s3. It may vary depending on your hardware.


Method 1: Using systemd-networkd

This is the default network manager for systemd-based systems like Arch Linux. It is lightweight, fast, and ideal for servers or minimal installations.

Step 1: Enable systemd-networkd

sudo systemctl enable systemd-networkd.service
sudo systemctl start systemd-networkd.service

Also, enable systemd-resolved for DNS:

sudo systemctl enable systemd-resolved.service
sudo systemctl start systemd-resolved.service

Then link the resolv.conf to systemd:

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

Step 2: Create a Network Configuration File

Create a file named after your interface in /etc/systemd/network/, for example:

sudo nano /etc/systemd/network/20-wired.network

Add the following content:

[Match]
Name=enp0s3

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

Replace enp0s3 with your actual interface name, and adjust IP, gateway, and DNS as needed.

Step 3: Restart the Network

Restart systemd-networkd:

sudo systemctl restart systemd-networkd

You can verify the configuration using:

ip addr

And check the connectivity with:

ping archlinux.org

Method 2: Using NetworkManager (for Desktop Environments)

NetworkManager is commonly used on desktops and provides both GUI and CLI tools (nmcli) for managing network settings.

Step 1: Ensure NetworkManager is Running

If you use GNOME, KDE, or another desktop environment, NetworkManager is likely already running. Otherwise, you can install and enable it:

sudo pacman -S networkmanager
sudo systemctl enable NetworkManager.service
sudo systemctl start NetworkManager.service

Step 2: Set Static IP Using nmcli

List connections:

nmcli connection show

You’ll see something like:

NAME                UUID                                  TYPE      DEVICE 
Wired connection 1  a1b2c3d4-e5f6-7890-abcd-ef1234567890  ethernet  enp0s3

Now set the static IP:

nmcli connection modify "Wired connection 1" ipv4.addresses 192.168.1.100/24
nmcli connection modify "Wired connection 1" ipv4.gateway 192.168.1.1
nmcli connection modify "Wired connection 1" ipv4.dns "8.8.8.8 1.1.1.1"
nmcli connection modify "Wired connection 1" ipv4.method manual

Then bring the connection down and up again:

nmcli connection down "Wired connection 1"
nmcli connection up "Wired connection 1"

Step 3: Verify Settings

Check IP address:

ip addr show enp0s3

Check DNS:

cat /etc/resolv.conf

Method 3: Using netctl (Legacy and Minimal)

netctl is a profile-based networking tool provided by Arch but is not enabled by default in modern installations. It’s still useful for minimal setups and VMs.

Step 1: Install netctl (if needed)

sudo pacman -S netctl

Step 2: Use an Example Profile

Start by copying an example profile:

sudo cp /etc/netctl/examples/ethernet-static /etc/netctl/my-static

Edit the file:

sudo nano /etc/netctl/my-static

Set the interface and IP details:

Interface=enp0s3
Connection=ethernet
IP=static
Address=('192.168.1.100/24')
Gateway='192.168.1.1'
DNS=('8.8.8.8' '1.1.1.1')

Step 3: Enable and Start the Profile

Start the connection:

sudo netctl start my-static

Enable it at boot:

sudo netctl enable my-static

To disable DHCP or other conflicting services, ensure dhcpcd or other managers are stopped and disabled.


Common Troubleshooting Tips

1. IP Address Not Assigned

  • Check that you disabled conflicting services like dhcpcd or other network managers.
  • Use journalctl -xe to view system logs for errors.

2. Can’t Reach External Network

  • Ensure the gateway is correct.
  • Test by pinging the gateway: ping 192.168.1.1
  • Check your DNS: try pinging by IP (e.g., ping 8.8.8.8) and hostname (ping google.com).

3. DNS Not Working

  • Verify that /etc/resolv.conf is correctly pointing to working DNS servers.
  • Make sure no other service is overwriting resolv.conf.

4. Conflicting Services

Make sure only one network management method is in control. For example, don’t use systemd-networkd and NetworkManager simultaneously unless you explicitly configure them not to conflict.


Choosing the Right Tool for the Job

Use CaseRecommended Method
Desktop usersNetworkManager
Servers or headless systemssystemd-networkd
Lightweight VMs or legacy setupsnetctl

Each method has its place. systemd-networkd is now the de facto standard for minimal or server-oriented installations, while NetworkManager is convenient for GUI-based environments.


Conclusion

Setting a static IP address on Arch Linux is a straightforward process once you understand which network management tool you’re using. Whether you’re configuring a server, setting up a development environment, or creating a stable local IP for remote access, having a static IP is essential for consistency.

With methods ranging from systemd-networkd for lean environments, to NetworkManager for user-friendly desktop control, Arch Linux gives you the flexibility to tailor your networking setup exactly to your needs.

Take some time to experiment with each method in a test environment if you’re not sure which one fits best. The more comfortable you get with configuring network interfaces manually, the more control and reliability you’ll gain from your Linux setup.