Enforce Coding Standards with PHP_CodeSniffer and Eclipse IDE on Ubuntu Linux
Symfony 2 Crash Course
Book Review: How to Implement Design Patterns in PHP
Native Linux Space Warfare: Freespace 2
Nice n' Easy JQuery Image Rotator
Using PHP pspell Spell Check Functions with a Custom Dictionary

Switching from netctl to networkd with iwd

Sunday, 12 January 20, 9:31 am
On a fresh install of Arch Linux, systemd will be set up with its default network service, networkd, and its name resolution service, systemd-resolved, enabled along with a configuration file that will create a wired ethernet connection using DHCP. For existing installations, this service won't necessarily be running, so check with:
systemctl status systemd-resolved systemd-resolved
If either are not already running, start and enable them:
sudo systemctl enable --now systemd-networkd systemd-resolved

Wired/Ethernet Connections

We've now got all we need to establish wired ethernet networks. For each connection, you'll need to create a config file in /etc/systemd/network/ with a name that ends in .network. These will be processed in alphabetical order, so the convention of starting the filename with a number applies. The first file which matches a device will be used: any subsequent files which also match are ignored. I like to give my computers static IPs for predictability, so for a wired connection, I would create a file called /etc/systemd/network/10-static-wired.network with the following contents:
[Match] Name=eth0   [Network] Address=192.168.1.55/24 Gateway=192.168.1.1 DNS=192.168.1.1
The Name in the Match section should be the name of your network adapter, so you may need to change that for your system. Note that wildcards are supported, e.g. Name=en* would match an external ethernet dongle regardless of what USB port it is plugged in to.

Prioritising Multiple Networks

If you may sometimes have more than one connection active at once, you can give each one a different route metric, and the system will use the route with the lowest metric. For static routes, you do this by adding a Metric setting under the Route section. We should also move the Gateway setting into this section, as it is only allowed in Network as a shorthand when it is the only route setting. Here's how the network config might look with these changes:
[Match] Name=eth0   [Network] Address=192.168.1.55/24 DNS=192.168.1.1   [Route] Gateway=192.168.1.1 Metric=10

Wireless Connections with iwd

First you need to install iwd. Then start/enable it:
sudo systemctl enable --now iwd
Assuming you want to have iwd assign IP addresses using its built-in DHCP client or using static IP addresses you define in configuration files, you will need to create /etc/iwd/main.conf with the following:
[General] EnableNetworkConfiguration=true
If you miss this step, you will get errors like "ping: connect: Network is unreachable" when trying to ping IP addresses or ping: rdeeson.com: Name or service not known when trying to ping websites.

Another setting you might wish to add to /etc/iwd/main.conf is the inconsistently cased route_priority_offset. This integer value is added to all iwd connections' route metrics, and is useful if you want to ensure all wireless connections have lower priority than wired connections:
[General] route_priority_offset=300
We're now ready to set up a connection. The easiest way to create a wireless connection profile is with the iwctl command-line tool. Run this command as a normal user, not as root. For each connection that you create, there will be a corresponding file in /var/lib/iwd/ with the name <SSID>.psk which holds the connection password (the Pre-Shared Key). Additional configuration should also be added to this file as required. For instance, to use a static IP of 192.168.0.55 for the connection, you would use:
[IPv4] ip=192.168.0.55 netmask=255.255.255.0 gateway=192.168.0.1 broadcast=192.168.0.255 dns=192.168.0.1

Please enter your comment in the box below. Comments will be moderated before going live. Thanks for your feedback!

Cancel Post

/xkcd/ Number Shortage