How do I set up a static IP address in Arch Linux?

Setting up a static IP address in Arch Linux provides users with a stable and predictable network configuration. Whether you’re configuring a server or prefer a fixed IP for your desktop system, the process involves understanding the network interface, editing configuration files, and ensuring proper connectivity. In this comprehensive guide, we’ll walk through the step-by-step process of configuring a static IP address in Arch Linux.

Identifying Network Interfaces

1. List Network Interfaces:

Identify the available network interfaces on your system using the ip link or ip a command:

ip link

2. Choose the Interface:

Select the network interface for which you want to set a static IP address. Common interfaces include eth0 for wired connections and wlan0 for wireless connections.

Configuring a Static IP Address

1. Using netctl:

a. Create a Profile:

Create a netctl profile for the chosen interface. Replace eth0 with your interface name:

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

b. Edit the Profile:

Open the profile using a text editor:

sudo nano /etc/netctl/eth0

c. Configure the IP Address:

Modify the file to include the desired static IP address, gateway, and DNS servers:

Address=('192.168.1.2/24')
Gateway=('192.168.1.1')
DNS=('8.8.8.8' '8.8.4.4')

d. Enable and Start the Profile:

Enable and start the netctl profile:

sudo netctl enable eth0
sudo netctl start eth0

2. Using systemd-networkd:

a. Create a Network Configuration File:

Create a file in /etc/systemd/network/ for the chosen interface, e.g. 20-eth0.network:

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

b. Configure the File:

Add the following content, replacing the values with your desired static configuration:

[Match]
Name=eth0

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

c. Enable and Start systemd-networkd:

Enable and start the systemd-networkd service:

sudo systemctl enable systemd-networkd
sudo systemctl start systemd-networkd

Checking Network Status

1. Verify the Configuration:

Check the IP configuration of the interface using ip a or ip addr show. Ensure that the static IP address, gateway, and DNS settings are correctly applied.

2. Test Connectivity:

Verify network connectivity by pinging a known IP address or domain:

ping 8.8.8.8

3. Check Systemd Service Status:

If using systemd-networkd, check the status of the service:

sudo systemctl status systemd-networkd

Troubleshooting

1. Incorrect Configuration:

Double-check the configuration files for syntax errors or typos.

2. Restart Network Services:

Restart the relevant network services to apply changes:

sudo systemctl restart netctl@eth0
sudo systemctl restart systemd-networkd

3. Review Journal Logs:

Check the journal logs for any networking-related issues:

journalctl -xe | grep network

Conclusion

Configuring a static IP address in Arch Linux involves creating or modifying network profiles and ensuring that the changes are applied correctly. Whether using netctl or systemd-networkd, this step-by-step guide should help you navigate the process and establish a stable and predictable network configuration on your Arch Linux system. Remember to check for connectivity, verify the configuration, and troubleshoot any issues that may arise during the setup.

Scroll to Top