RackNerd Billboard Banner

How To Configure Static IP And Dynamic IP Address In Arch Linux

Setting up a network connection in Arch Linux can be intimidating at first, but once you know the tools, it’s straightforward. This guide covers how to configure both static and dynamic IP addresses using systemd-networkd and netctl, two commonly used tools in Arch.


Prerequisites

Before configuring anything, make sure:

  • You’re using Arch Linux or an Arch-based distro.
  • You have root privileges (sudo access).
  • Your network interface name is known (e.g., enp0s3, eth0, wlan0).

To list your network interfaces:

ip link

Option 1: Configure a Dynamic IP (DHCP) with systemd-networkd

Dynamic IPs are assigned automatically by your router. Here’s how to enable it:

1. Create a Network Configuration File

Create a file at /etc/systemd/network/20-wired.network (replace wired with a name that makes sense to you):

[Match]
Name=enp0s3

[Network]
DHCP=yes

Replace enp0s3 with your actual interface name.

2. Enable and Start systemd-networkd

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

3. (Optional) Enable systemd-resolved for DNS

sudo systemctl enable systemd-resolved.service
sudo systemctl start systemd-resolved.service
sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

Option 2: Configure a Static IP with systemd-networkd

If you want a fixed IP:

1. Create the Configuration File

[Match]
Name=enp0s3

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

Save this as /etc/systemd/network/20-static.network.

2. Restart systemd-networkd

sudo systemctl restart systemd-networkd

Option 3: Use netctl (Alternative to systemd-networkd)

If you prefer netctl, here’s how to set up both DHCP and static IP.

Dynamic IP with netctl

sudo cp /etc/netctl/examples/ethernet-dhcp /etc/netctl/my-dhcp
sudo nano /etc/netctl/my-dhcp

Set Interface=enp0s3, save, then:

sudo netctl start my-dhcp
sudo netctl enable my-dhcp

Static IP with netctl

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

Edit the file like this:

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

Then start and enable:

sudo netctl start my-static
sudo netctl enable my-static

Troubleshooting Tips

  • Use journalctl -u systemd-networkd to debug systemd-networkd.
  • ping 8.8.8.8 to test connectivity.
  • If your changes don’t apply, check interface names or syntax errors in config files.

Conclusion

Whether you want the convenience of DHCP or the control of a static IP, Arch Linux gives you the tools—if you know where to look. systemd-networkd is lightweight and integrates well with modern systems, while netctl is still a valid alternative for traditionalists.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

RackNerd Billboard Banner
Copy link