Arch Linux network configuration

ifraixedes

Ivan Fraixedes

Posted on October 30, 2024

Arch Linux network configuration

This post is part of a series of posts about installing and configuring Arch Linux in a Slimbook Executive 14". I created them from a collection of personal notes, that I thought may be useful for others, so I published them through these series.

  1. Base Arch Linux installation
  2. Arch Linux network configuration

NOTE because all the operations require root permissions, I logged as root with sudo su, so all the commands in this post don't execute with sudo.

I decided to use systemd-networkd to deal with the network configuration, and I decided to fully commit to it, so I used systemd-resolved for configuration the network name resolution (a.k.a DNS). Bear in mind that my laptop only has one network interface (apart of the loopback interface).

Both services are part of the base Arch Linux installation.

I enable the systemd-networkd, so it automatically starts at boot (i.e. systemctl enable systemd-networkd.service). After executing it, you'll see a list of created symlinks in /etc/systemd/system and sub-directories to /usr/lib/systemd/system directory, not important, but I wanted to point it out.

I configured the systemd-networkd-wait-online.service which is a oneshot system service that waits for the network to be configured. I edited the file /etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service which is a symlink to /usr/lib/systemd/system/systemd-networkd-network-wait-online.service, adding the --any flag to the following line

ExecStart=/usr/lib/systemd/systemd-networkd-wait-online --any
Enter fullscreen mode Exit fullscreen mode

To configure the wireless adapter, I created a new file, /etc/systemd/network/25-wireless.network, with the following content

[Match]
Name=wlan0

[Network]
DHCP=yes
IgnoreCarrierLoss=3
Enter fullscreen mode Exit fullscreen mode

To obtain the name of the wireless adapter, I executed ip link.

Everything should be fine at this point, so I started the service systemd start systemd-netword.service.

Next is to configure name resolution service (TODO review if name resolution service is correct) through the systemd-resolved service.

I started enabling systemctl enable systemd-resolved.service which, as before it created some symlinks . Right after, I started it systemctl start systemd-resolved.service.

I replaced the /etc/resolv.conf by a symlink ln -sf ../run/systemd/resolve/stub-resolve.conf /etc/resolv.conf, the service had to be active, otherwise the runtime configuration (the file /run/systemd/resolve/stub-resolve.conf) didn't exist and the symlink creating would have failed.

I checked the DNS currently in use with resolvectl status and it was great, it gave me the DNS servers configured on my router.

Last, I configured the Wi-FI through the iwd, which I already installed in the base installation

First, I created the iwd network configuration file /var/lib/iwd/foo.psk, where foo is the SSID of my home Wi-FI network.

I opened the file with the editor and wrote

[Security]
Passphrase=I typed here for you to know it
Enter fullscreen mode Exit fullscreen mode

Then, I started the service (systemctl start iwd.service) and confirmed that I could ping some external sites.

After this, I edited the above file to remove the passphrase because the pre-shared key was written it, so it doesn't need to be there anymore.

Because, I didn't want iwd to scan periodically for networks when it's in a disconnected state, I created the /etc/iwd/main.conf file, opened with the editor, and wrote:

[Scan]
DisablePeriodicScan=true
Enter fullscreen mode Exit fullscreen mode

Last but not least, I want the service to automatically start at boot, hence I enabled the service (systemctl enable iwd.service), which created some symlinks as before.

This is all, I rebooted my computer and I could verify that it connects automatically to my home Wi-Fi network.

💖 💪 🙅 🚩
ifraixedes
Ivan Fraixedes

Posted on October 30, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related