Okay, let's figure out how your network is likely configured on your Arch Linux system without NetworkManager, and how to set up a static IP address.
Likely Scenario: systemd-networkd
The most common scenario in Arch Linux when you haven't explicitly installed NetworkManager (or similar) is that you're using systemd-networkd. systemd-networkd is a lightweight network management daemon included with systemd. It's often the default choice for simple network configurations, especially on server-type setups.
Steps to Configure a Static IP using systemd-networkd:
-
Identify Your Network Interface Name:
-
Use the ip link command. Look for the Ethernet interface that's currently "UP" (or "LOWER_UP"). Common names are eth0, enp0s3, enp3s0, enp4s0, etc. This is crucial you get this right.
ip link
-
Example output (your output will be different):
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether 08:00:27:d1:de:ad brd ff:ff:ff:ff:ff:ff
In this example, the Ethernet interface is enp0s3.
-
Create a Network Configuration File:
-
You'll create a file in /etc/systemd/network/ to define the network settings for your interface. The filename must end in .network. It's conventional to name it something related to the interface, like 10-static-enp0s3.network (replace enp0s3 with your actual interface name). The 10- prefix is to help with ordering if you have multiple network files.
sudo nano /etc/systemd/network/10-static-enp0s3.network # Replace enp0s3
-
Populate the Configuration File:
-
Add the following content to the file. Modify the values to match your network's settings!
[Match]
Name=enp0s3 # Replace with your interface name
[Network]
Address=192.168.1.100/24 # Your desired static IP address and subnet mask (e.g., /24 for 255.255.255.0)
Gateway=192.168.1.1 # Your router's IP address
DNS=8.8.8.8 # Google's public DNS server (you can use another DNS server)
DNS=8.8.4.4
-
Explanation:
[Match] section:
Name=enp0s3: Specifies which network interface this configuration applies to. This is the critical part. Make sure it matches the output of ip link.
[Network] section:
Address=192.168.1.100/24: Sets the static IP address. The /24 represents the subnet mask 255.255.255.0. Adjust this to your network.
Gateway=192.168.1.1: Sets the default gateway (your router). Change to the actual IP address of your router. Often, this is the same address you'd type into a web browser to access your router's configuration page.
DNS=8.8.8.8: Sets the primary DNS server. I've used Google's public DNS. You can use your ISP's DNS servers or other public DNS servers.
DNS=8.8.4.4: Sets the secondary DNS server.
-
Restart systemd-networkd and systemd-resolved:
-
Apply the changes by restarting the network service.
sudo systemctl restart systemd-networkd
sudo systemctl restart systemd-resolved #Important, some setups won't work without this
-
Verify the Configuration:
-
Use ip addr show enp0s3 (replace enp0s3 with your interface name) to verify that the interface has the correct IP address.
ip addr show enp0s3
-
You should see the IP address you configured in the output. Look for the inet line under your interface.
-
Test connectivity: Try pinging your gateway and a public website.
ping 192.168.1.1 # Replace with your gateway address
ping google.com
Important Considerations and Troubleshooting:
-
Conflicts: Make sure the static IP address you choose is not already in use by another device on your network. IP address conflicts will cause network problems. Choose an address outside the DHCP range of your router (if your router is using DHCP). Consult your router's documentation for how to determine or configure the DHCP range.
-
Subnet Mask: The subnet mask (e.g., /24) is very important. It defines the size of your network. Almost all home networks use /24 (255.255.255.0). If you're unsure, use /24. Using the wrong subnet mask will prevent communication.
-
Gateway: The gateway is the IP address of your router. It's how your computer reaches the internet. If the gateway is incorrect, you won't have internet access.
-
DNS: If you can ping the gateway but not websites (e.g., ping google.com fails), the problem is likely with your DNS settings. Double-check the DNS server addresses in your configuration file. You can temporarily try using Google's DNS (8.8.8.8 and 8.8.4.4) to see if that resolves the issue.
-
Firewall: Arch Linux commonly uses iptables or nftables for firewalling. Ensure that your firewall rules allow outbound DNS traffic (port 53, both TCP and UDP) and general outbound traffic. However, default Arch installations usually don't have restrictive firewalls. This is less likely to be the issue, but something to consider if you've configured a firewall.
-
Conflicts with NetworkManager: If you later install NetworkManager, it may conflict with systemd-networkd. If you decide to use NetworkManager, you'll need to disable systemd-networkd and remove the network configuration files you created. To disable systemd-networkd:
sudo systemctl stop systemd-networkd
sudo systemctl disable systemd-networkd
-
Link-Local Addressing: If you configure something incorrectly and can't get an IP address, your interface might get a "link-local" address in the 169.254.x.x range. This means it couldn't get a DHCP address or wasn't configured correctly, and it's not routable.
If systemd-networkd is NOT running
If systemctl status systemd-networkd shows that the service is not running and is disabled, it is less likely to be your network configuration method. In this case you may be using a legacy method like editing /etc/network/interfaces or using dhcpcd directly. If this is the case please provide the output of cat /etc/network/interfaces or cat /etc/dhcpcd.conf
How to get more information
journalctl -u systemd-networkd: Shows the logs for systemd-networkd. This is extremely helpful for debugging problems. Look for error messages. Use the -f option to follow the logs in real-time while restarting the service.
networkctl status: Provides a summary of network interfaces and their status.
Example Scenario
Let's say your network details are:
- Interface name:
enp0s3
- Desired static IP:
192.168.1.150
- Gateway:
192.168.1.1
- Subnet mask:
255.255.255.0 (which is equivalent to /24)
- DNS:
8.8.8.8 and 8.8.4.4
The file /etc/systemd/network/10-static-enp0s3.network would look like this:
[Match]
Name=enp0s3
[Network]
Address=192.168.1.150/24
Gateway=192.168.1.1
DNS=8.8.8.8
DNS=8.8.4.4
Remember to adapt all these instructions to your specific network configuration! I hope this helps! Good luck!