iwd - Internet Wireless Daemon on Alpine Linux

2020-01-20

To install it on Alpine enable community repository to apk (if it is not enabled already) by removing # in front of the line:

#https://nl.alpinelinux.org/alpine/edge/community
to be:
https://nl.alpinelinux.org/alpine/edge/community

and then do:

to enable it at boot:
rc-update add iwd

it could be managed by 'root' but for security reasons it should managed as ordinary user which must be member of the netdev group.

To add user in netdev group (if it isn't there already) run as root: adduser username netdev then user must logout (if it is logged in) and login again.

if the wireless device is blocked it could be activated/unblocked by: rfkill unblock all or particular device rfkill unblock 0

General management

then run 'iwctl' - iw control utility
iwctl

iwctl can be run in interactive mode with prompt and command line editing like this and there should be a prompt like this:
[iwd]#
where commands can be typed

[iwd]# quit to exit cli

other option is to run iwctol and give commands after it in shell for example:
iwctl help will show short help

iwctl adapter list will show wireless adapters available, physical adapters, example:

                                    Adapters                                  *
--------------------------------------------------------------------------------
  Name               Powered   Vendor              Model
--------------------------------------------------------------------------------
  phy0               on        --

to get detailed info about adapter:

iwctl adapter phy0 show

                                 Adapter: phy0
--------------------------------------------------------------------------------
  Settable  Property         Value
--------------------------------------------------------------------------------
            Name             phy0
         *  Powered          on
            Vendor
            Model
            SupportedModes   ad-hoc station ap

it show some basic info about adapter and modes which it supports

if the Powered field shows 'off' adapter can be activated (powered) by issuing command:
iwctl adapter phy0 set-property Powered on

of course it can be powered of by issuing:
iwctl adapter phy0 set-property Powered off

device command manages and shows device status

to show available wireless devices and some information about it, example:

iwctl device list

--------------------------------------------------------------------------------
  Name                Address             Powered   Adapter   Mode
--------------------------------------------------------------------------------
  wlan0               fe:cd:12:34:56:78   on        phy0      ap

detailed info about particular device could be shown by:
iwctl device wlan0 show

                                 Device: wlan0
--------------------------------------------------------------------------------
  Settable  Property            Value
--------------------------------------------------------------------------------
            Name                wlan0
         *  Mode                ap
         *  Powered             on
            Address             fe:cd:12:34:56:78
         *  WDS                 off
            Adapter             phy0

set AP (Access Point) mode

to use it in real work there should be DHCP server, ethernet interface and other things which depends on use case scenario

iwctl device wlan0 set-property Mode ap
if works there will be no answer, else there will be error shown

to put device in ap mode issue next command with appropriate parameters:
iwctl ap wlan start ssid passphrase
where ssid is a 'network name' and 'passphrase' is desired passphrase (at least eight charaters long)

and, iwctl ap list will show a state of AP


                          Devices in Access Point Mode
--------------------------------------------------------------------------------
  Name                Started
--------------------------------------------------------------------------------
  wlan0               yes

to stop AP next command should be issued:
iwctl ap wlan0 stop


Station (wireless client) mode

iwctl device wlan0 set-property Mode station if works there will be no answer, else there will be error shown

to scan networks issue command: iwctl station wlan0 scan

to see list of available networks (access points) issue: iwctl station wlan0 get-networks

and there should be list, like this

                               Available networks
--------------------------------------------------------------------------------
    Network name                    Security  Signal
--------------------------------------------------------------------------------
    xyz                             psk       ****
    abc                             psk       ****
    a23ek                           psk       ****
    ced astra                       psk       ****
    ZTE_HXXXXXXXX09                 psk       ****
    AX305f                          open      ****

to connect to one of these networks

iwctl station wlan0 connect network-name and there should be promt:

Type the network passphrase for abc psk
Passphrase:

where passphrase should be typed


On old iwd versions first time connect to network interactive mode of iwctl must be used because it doesn't ask for passphrase in cli mode, so: iwctl and there should be a prompt like this: [iwd]#

then issue command (without passphrase)
[iwd]# station wlan0 connect network-name


iwd remembers networks in files under /var/lib/iwd directory in files named according to network name with auth type extension. and passphrase not needed next time, for example network 'abc' will be in /var/lib/iwd/abc.psk

so, next time is enough to issue command from shell iwctl station wlan0 connect network-name

and next times it will not ask for phassprase until the network file in /var/lib/iwd isn't deleted/renamed


to disconnect simply type
iwctl station wlan0 disconnect

then adapter could be powered down
adapter phy0 set-property Powered off