archlinux

27 - Network configuration

Previous: Reboot the system

References:


Login as a regular user and use sudo to execute commands as superuser.

We will configure the network to connect automatically to the internet.

Network manager

Use systemd-networked as the network manager:

Networkd is already installed on the computer as it is part of systemd.

Create a config file for a wireless adapter with

sudo nano /etc/systemd/network/25-wireless.network

Add (replace wlan0 accordingly)

[Match]
Name=wlan0

[Link]
RequiredForOnline=routable

[Network]
DHCP=yes
MulticastDNS=yes
IgnoreCarrierLoss=3s

Enable

sudo systemctl enable systemd-networkd.service --now

After reboot, check status with

networkctl

and

networkctl status

Authentication

Use iwd to authenticate (we have already installed it):

Enable

sudo systemctl enable iwd.service --now

After reboot, check status with

systemctl status iwd.service

DNS configuration

Use systemd-resolved to manage DNS:

Resolved is already installed on the computer as it is part of systemd.

Enable

sudo systemctl enable systemd-resolved.service --now

Replace /etc/resolve.conf with a symbolic link to stub-resolv.conf:

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

After reboot, check status with

resolvectl

mDNS configuration

Use systemd-resolved to manage mDNS:

It is enabled by default with systemd-resolved. The interfaces must be configured to use mDNS as described above (with MulticastDNS=yes).

After reboot, try local DNS resolution with (replace myhostname accordingly)

ping -c 3 myhostname.local

Timesyncd

Use systemd-timesync to manage time synchromization:

Timesyncd is already installed on the computer as it is part of systemd.

Edit the config file with

sudo nano /etc/systemd/timesyncd.conf

Add

NTP=time.google.com

Enable

sudo systemctl enable systemd-timesyncd.service --now

After reboot, check status with

timedatectl status

or

timedatectl timesync-status --all

Connect to wifi

Use the client iwctl:

First, check for software blocks (to avoid errors):

rfkill list

Look for “Soft blocked: yes” or “Hard blocked: yes” next to your wireless device. Unblock the device (actually, all the devices):

rfkill unblock all

Run rfkill list again to confirm that the block is gone.

In the command line, enter the following (replace wlan0 and network_name accordingly):

iwctl
device list
station wlan0 scan
station wlan0 get-networks
station wlan0 connect network_name
station wlan0 show
quit

Note: To connect to a network with spaces in the SSID, the network name should be double quoted (for example, “my network”).

The program iwd automatically stores network passphrases in the /var/lib/iwd directory and uses them to auto-connect in the future.

Internet connection should work. Check the connection with

ping -c 3 www.google.com

To verify that automatic connection is working, reboot the system:

sudo reboot

Login as user an execute the following commands (replace myhostname accordingly):

ping -c 3 www.google.com
networkctl
networkctl status
systemctl status iwd.service
resolvectl
ping -c 3 myhostname.local
timedatectl status
timedatectl timesync-status --all

Verify the output of each command.

To check swap, execute

systemctl status systemd-zram-setup@zram0.service
zramctl
swapon --show

Next: Install a graphical environment