Skip to content

Instantly share code, notes, and snippets.

@valyakuttan
Last active August 19, 2021 04:22
Show Gist options
  • Save valyakuttan/8550d9632d1fa25b9a0923157840e689 to your computer and use it in GitHub Desktop.
Save valyakuttan/8550d9632d1fa25b9a0923157840e689 to your computer and use it in GitHub Desktop.

Simple wifi with iwd and networkd for Arch Linux

Original source.

Install and Configure iwd

  1. Install iwd

         $ sudo pacman -S iwd
  2. Configure iwd by editing /etc/iwd/main.conf

         [General]
         # uncomment for setting the wifi interface name yourself
         # see https://iwd.wiki.kernel.org/interface_lifecycle
         #UseDefaultInterface=true
    
         # enable builtin DHCP-client within iwd for wifi
         EnableNetworkConfiguration=true
    
         # randomizes mac-address every time iwd starts or the hardware is initially detected
         AddressRandomization=once
  3. Enable iwd.service

         $ sudo systemctl enable --now iwd.service

    wireless networking with DHCP is now up and running.

Connect to simple PSK wifi networks in the iwctl shell:

  1. To get an interactive prompt do:

         $ iwctl
  2. If you do not know your wireless device name, list all Wi-Fi devices:

         [iwd]# device list
  3. To connect to a network:

        [iwctl] station <devicename> get-networks
        …
        [iwctl] station <devicename> connect <network-name>
  4. Alternatively, you can supply it as a command line argument:

         $ iwctl --passphrase passphrase station device connect SSID

Configure systemd-resolved for DNS

  1. Enable systemd-resolved.service

         $ sudo systemctl enable --now systemd-resolved.service
  2. Make /etc/resolv.conf as a symlink to /run/systemd/resolve/stub-resolv.conf

         $ sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
  3. Restart systemd-resolved.service

         $ sudo systemctl restart systemd-resolved.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment