Wi-Fi: Difference between revisions
(→Rfkill: remove wrong usage of Cat template) |
(formatting, templates) |
||
Line 12: | Line 12: | ||
== iwd == | == iwd == | ||
[ | [[Iwd]] (iNet wireless daemon) is a wireless daemon written by Intel and aiming at replacing {{Pkg|wpa_supplicant}}. The core goal of the project is to optimize resource utilization by not depending on any external libraries and instead utilizing features provided by the Linux Kernel to the maximum extent possible. | ||
{{Pkg|iwd}} is supported since [https://alpinelinux.org/posts/Alpine-3.10.0-released.html Alpine Linux 3.10]. | {{Pkg|iwd}} is supported since [https://alpinelinux.org/posts/Alpine-3.10.0-released.html Alpine Linux 3.10]. | ||
Line 18: | Line 18: | ||
To get started, install {{Pkg|iwd}}: | To get started, install {{Pkg|iwd}}: | ||
{{Cmd|apk add iwd}} | {{Cmd|# apk add iwd}} | ||
To do anything with iwd, it has to be running: | To do anything with iwd, it has to be running: | ||
{{Cmd|rc-service iwd start}} | {{Cmd|# rc-service iwd start}} | ||
If it was not running, running <code>iwctl ..</code> commands will print | If it was not running, running <code>iwctl ..</code> commands will print | ||
Line 33: | Line 33: | ||
List your available wifi device(s) (you probably have ''wlan0''): | List your available wifi device(s) (you probably have ''wlan0''): | ||
{{Cmd|iwctl device list}} | {{Cmd|$ iwctl device list}} | ||
If you don't know the SSID of your network you can run a scan and retrieve a list of all the detected networks: | If you don't know the SSID of your network you can run a scan and retrieve a list of all the detected networks: | ||
{{Cmd|iwctl station wlan0 scan && iwctl station wlp8s0 get-networks}} | {{Cmd|$ iwctl station wlan0 scan && iwctl station wlp8s0 get-networks}} | ||
To connect to a network: | To connect to a network: | ||
{{Cmd|iwctl station wlan0 connect <SSID>}} | {{Cmd|$ iwctl station wlan0 connect <SSID>}} | ||
<br> | <br> | ||
{{Note|iwd automatically stores network passphrases in the /var/lib/iwd directory and uses them to auto-connect in the future. If you run diskless Alpine, make sure to include this directory to the apkovl and commit: | {{Note|iwd automatically stores network passphrases in the /var/lib/iwd directory and uses them to auto-connect in the future. If you run diskless Alpine, make sure to include this directory to the apkovl and commit: | ||
{{Cmd|lbu add /var/lib/iwd && lbu commit -d}}}} | {{Cmd|# lbu add /var/lib/iwd && lbu commit -d}}}} | ||
{{Note|Since version 1.10, iwd supports IPv6, but it is disabled by default. To enable it, add the following to the configuration file: | {{Note|Since version 1.10, iwd supports IPv6, but it is disabled by default. To enable it, add the following to the configuration file: | ||
Line 55: | Line 55: | ||
Finally, configure {{Pkg|iwd}} and its dependency {{Pkg|dbus}} to start automatically on boot: | Finally, configure {{Pkg|iwd}} and its dependency {{Pkg|dbus}} to start automatically on boot: | ||
{{Cmd|rc-update add iwd boot && rc-update add dbus boot}} | {{Cmd|# rc-update add iwd boot && rc-update add dbus boot}} | ||
<br> | <br> | ||
Line 63: | Line 63: | ||
iface wlan0 inet dhcp}} | iface wlan0 inet dhcp}} | ||
{{Note|You could instead use the iwd's built-in network configuration by setting | {{Note|You could instead use the iwd's built-in network configuration by setting <code>EnableNetworkConfiguration{{=}}true</code> in {{Path|/etc/iwd/main.conf}} | ||
{{Cat|/etc/iwd/main.conf|#[General] | |||
... | |||
EnableNetworkConfiguration{{=}}True | |||
...}} | |||
}} | |||
<br> | <br> | ||
Line 69: | Line 74: | ||
Manually restart '''networking''': | Manually restart '''networking''': | ||
{{Cmd|rc-service networking restart}} | {{Cmd|# rc-service networking restart}} | ||
<br> | <br> | ||
Your wifi interface should now be up and have a dedicated IP adress: | Your wifi interface should now be up and have a dedicated IP adress: | ||
{{Cmd|ip a show wlan0}} | {{Cmd|$ ip a show wlan0}} | ||
<br> | <br> | ||
Line 84: | Line 89: | ||
To get started install {{Pkg|wpa_supplicant}} | To get started install {{Pkg|wpa_supplicant}} | ||
{{Cmd|apk add wpa_supplicant}} | {{Cmd|# apk add wpa_supplicant}} | ||
<br> | <br> | ||
Line 100: | Line 105: | ||
Bring up the desired interface: | Bring up the desired interface: | ||
{{Cmd|ip link set wlan0 up}} | {{Cmd|# ip link set wlan0 up}} | ||
{{Note|If this errors with <code>ioctl 0x8914 failed: No error information</code>, that's <code>busybox ip</code>'s way of saying your wireless radio is rfkill'd. See the [[#Rfkill|Rfkill section]] for information on how to unblock your wireless radio.}} | {{Note|If this errors with <code>ioctl 0x8914 failed: No error information</code>, that's <code>busybox ip</code>'s way of saying your wireless radio is rfkill'd. See the [[#Rfkill|Rfkill section]] for information on how to unblock your wireless radio.}} | ||
Line 107: | Line 112: | ||
Use this command to add your Wi-Fi network to wpa_supplicant: | Use this command to add your Wi-Fi network to wpa_supplicant: | ||
{{Cmd|wpa_passphrase 'ExampleWifiSSID' 'ExampleWifiPassword' > /etc/wpa_supplicant/wpa_supplicant.conf}} | {{Cmd|# wpa_passphrase 'ExampleWifiSSID' 'ExampleWifiPassword' > /etc/wpa_supplicant/wpa_supplicant.conf}} | ||
''(Access point not broadcasting its SSID requires additional line <code>scan_ssid=1</code> in the file <code>wpa_supplicant.conf</code>)'' | ''(Access point not broadcasting its SSID requires additional line <code>scan_ssid=1</code> in the file <code>wpa_supplicant.conf</code>)'' | ||
Line 115: | Line 120: | ||
Start wpa_supplicant in the foreground to make sure the connection succeeds. | Start wpa_supplicant in the foreground to make sure the connection succeeds. | ||
{{Cmd|wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf}} | {{Cmd|# wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf}} | ||
<br> | <br> | ||
If all is well, run it as a daemon in the background by setting the {{Path|-B}} option. | If all is well, run it as a daemon in the background by setting the {{Path|-B}} option. | ||
{{Cmd|wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf}} | {{Cmd|# wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf}} | ||
<br> | <br> | ||
Configure the interface with an IP address. | Configure the interface with an IP address. | ||
{{Cmd|udhcpc -i wlan0}} | {{Cmd|# udhcpc -i wlan0}} | ||
Sanity check: the interface should have a {{Path|inet}} address. | Sanity check: the interface should have a {{Path|inet}} address. | ||
{{Cmd|ip addr show wlan0}} | {{Cmd|$ ip addr show wlan0}} | ||
<br> | <br> | ||
Line 144: | Line 149: | ||
Bring the interface down. | Bring the interface down. | ||
{{Cmd|ip link set wlan0 down}} | {{Cmd|# ip link set wlan0 down}} | ||
<br> | <br> | ||
Line 150: | Line 155: | ||
Manually restart (or '''start''') '''networking'''. | Manually restart (or '''start''') '''networking'''. | ||
{{Cmd|/etc/init.d/networking --quiet restart &}} | {{Cmd|# /etc/init.d/networking --quiet restart &}} | ||
<br> | <br> | ||
Line 200: | Line 205: | ||
{{Cmd|rc-update add wpa_cli boot}} | {{Cmd|# rc-update add wpa_cli boot}} | ||
<br> | <br> | ||
Line 212: | Line 217: | ||
You can check if you have a Broadcom chipset by using lspci: | You can check if you have a Broadcom chipset by using lspci: | ||
{{Cmd|lspci -nn -d 14e4:}} | {{Cmd|$ lspci -nn -d 14e4:}} | ||
Now we need fwcutter: | Now we need fwcutter: | ||
{{Cmd|apk add b43-fwcutter}} | {{Cmd|# apk add b43-fwcutter}} | ||
Now we have everything to download the proprietary driver and extract the firmware from it: | Now we have everything to download the proprietary driver and extract the firmware from it: | ||
{{Cmd|<nowiki>export FIRMWARE_INSTALL_DIR="/lib/firmware" | {{Cmd|<nowiki># export FIRMWARE_INSTALL_DIR="/lib/firmware" | ||
wget http://www.lwfinger.com/b43-firmware/broadcom-wl-5.100.138.tar.bz2 | $ wget http://www.lwfinger.com/b43-firmware/broadcom-wl-5.100.138.tar.bz2 | ||
tar xjf broadcom-wl-5.100.138.tar.bz2 | $ tar xjf broadcom-wl-5.100.138.tar.bz2 | ||
# b43-fwcutter -w "$FIRMWARE_INSTALL_DIR" broadcom-wl-5.100.138/linux/wl_apsta.o</nowiki>}} | |||
More information can be found [http://linuxwireless.sipsolutions.net/en/users/Drivers/b43/#Other_distributions_not_mentioned_above here]. | More information can be found [http://linuxwireless.sipsolutions.net/en/users/Drivers/b43/#Other_distributions_not_mentioned_above here]. | ||
Line 229: | Line 234: | ||
Now you need to use modprobe so the device will show up: | Now you need to use modprobe so the device will show up: | ||
{{Cmd|modprobe b43}} | {{Cmd|# modprobe b43}} | ||
Now continue with the normal instructions. | Now continue with the normal instructions. | ||
Line 243: | Line 248: | ||
Many laptops have a hardware button (or switch) to turn off wireless card, however, the card can also be blocked by kernel. This can be changed using rfkill. To show the current of your Wi-Fi: | Many laptops have a hardware button (or switch) to turn off wireless card, however, the card can also be blocked by kernel. This can be changed using rfkill. To show the current of your Wi-Fi: | ||
<pre> | <p style="background-color:#f9f9f9; border:1px dashed #2f6fab; line-height:1.1em; padding:1em; font-family:monospace; font-size:10pt; white-space:pre; overflow:auto;"><span style="color:green;">~</span>'''$''' rfkill list | ||
$ rfkill list | |||
0: phy0: wlan | 0: phy0: wlan | ||
Soft blocked: no | Soft blocked: no | ||
Hard blocked: no | Hard blocked: no | ||
</ | </p> | ||
<br> | <br> | ||
Line 262: | Line 266: | ||
* [[Installation#Post-Install|Post Install]] | * [[Installation#Post-Install|Post Install]] | ||
* [[Alpine setup scripts]] | * [[Alpine setup scripts]] | ||
* [[Iwd|iwd]] | |||
[[Category:Networking]] | [[Category:Networking]] |
Revision as of 09:35, 3 July 2023
This page describes how to set up a wireless network connection with WPA encryption.
Choose a wireless daemon between iwd and wpa_supplicant
Prerequisites
Working wireless drivers
If you are using a Broadcom chipset, see the Broadcom Wi-Fi section.)
iwd
Iwd (iNet wireless daemon) is a wireless daemon written by Intel and aiming at replacing wpa_supplicant. The core goal of the project is to optimize resource utilization by not depending on any external libraries and instead utilizing features provided by the Linux Kernel to the maximum extent possible.
iwd is supported since Alpine Linux 3.10.
To get started, install iwd:
# apk add iwd
To do anything with iwd, it has to be running:
# rc-service iwd start
If it was not running, running iwctl ..
commands will print
The name net.connman.iwd was not provided by any .service files Failed to retrieve IWD dbus objects, quitting...
and running just iwctl
will say it is waiting for IWD to start.
List your available wifi device(s) (you probably have wlan0):
$ iwctl device list
If you don't know the SSID of your network you can run a scan and retrieve a list of all the detected networks:
$ iwctl station wlan0 scan && iwctl station wlp8s0 get-networks
To connect to a network:
$ iwctl station wlan0 connect <SSID>
# lbu add /var/lib/iwd && lbu commit -d
Contents of /etc/iwd/main.conf
Finally, configure iwd and its dependency dbus to start automatically on boot:
# rc-update add iwd boot && rc-update add dbus boot
Add a entry for the desired interface (e.g. wlan0):
Contents of /etc/network/interfaces
EnableNetworkConfiguration=true
in /etc/iwd/main.conf
Contents of /etc/iwd/main.conf
Manually restart networking:
# rc-service networking restart
Your wifi interface should now be up and have a dedicated IP adress:
$ ip a show wlan0
Useful link: Archlinux wiki page if you need more specific configuration.
wpa_supplicant
To get started install wpa_supplicant
# apk add wpa_supplicant
To list your available network interfaces:
ip link
or
ip a
Bring up the desired interface:
# ip link set wlan0 up
ioctl 0x8914 failed: No error information
, that's busybox ip
's way of saying your wireless radio is rfkill'd. See the Rfkill section for information on how to unblock your wireless radio.
Use this command to add your Wi-Fi network to wpa_supplicant:
# wpa_passphrase 'ExampleWifiSSID' 'ExampleWifiPassword' > /etc/wpa_supplicant/wpa_supplicant.conf
(Access point not broadcasting its SSID requires additional line scan_ssid=1
in the file wpa_supplicant.conf
)
Start wpa_supplicant in the foreground to make sure the connection succeeds.
# wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
If all is well, run it as a daemon in the background by setting the -B option.
# wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
Configure the interface with an IP address.
# udhcpc -i wlan0
Sanity check: the interface should have a inet address.
$ ip addr show wlan0
Automatic Configuration on System Boot
Add a entry for the desired interface (e.g. wlan0):
Contents of /etc/network/interfaces
Sanity check: Make sure /etc/wpa_supplicant/wpa_supplicant.conf is the correct configuration for the wireless access point you want to connect to.
Bring the interface down.
# ip link set wlan0 down
Manually restart (or start) networking.
# /etc/init.d/networking --quiet restart &
If all is well (feel free to confirm with the sanity checks),
Configure wpa_supplicant to start automatically on boot:
# rc-update add wpa_supplicant boot
Also make sure networking is set to automatically start on boot:
# rc-update add networking boot
Optional security precaution:
By default wpa_supplicant will store your Wi-Fi password in plain text:
Contents of (Example) /etc/wpa_supplicant/wpa_supplicant.conf
this is not necessary and wpa_supplicant should funtion just fine without it, if you dont want your stored password in plain text just delete the line with #psk="<YourPasswordShouldBeHereInPlainText>"
on it.
Launching udhcpc through wpa_cli actions
With the above configuration, udhcpc will only run once at boot. If the Wifi isn't available then, or the network changes in between, it needs to be notified. This is done through the wpa_cli action script in /etc/wpa_supplicant/wpa_cli.sh
Automatic Reconnection when WIFI signal is lost
To enable automatic reconnection when wifi signal is lost add these to config:
Contents of /etc/wpa_supplicant/wpa_supplicant.conf
# rc-update add wpa_cli boot
Troubleshooting
Broadcom Wi-Fi Chipset Users
The Broadcom chipset is quite popular among older computers. The b43 driver is included in the linux-lts or linux-edge kernel packages. However, you might need to compile the firmware manually for this chipset as it is not included in linux-firmware for some cargs.
You can check if you have a Broadcom chipset by using lspci:
$ lspci -nn -d 14e4:
Now we need fwcutter:
# apk add b43-fwcutter
Now we have everything to download the proprietary driver and extract the firmware from it:
# export FIRMWARE_INSTALL_DIR="/lib/firmware" $ wget http://www.lwfinger.com/b43-firmware/broadcom-wl-5.100.138.tar.bz2 $ tar xjf broadcom-wl-5.100.138.tar.bz2 # b43-fwcutter -w "$FIRMWARE_INSTALL_DIR" broadcom-wl-5.100.138/linux/wl_apsta.o
More information can be found here.
Now you need to use modprobe so the device will show up:
# modprobe b43
Now continue with the normal instructions.
Rfkill
See Also: Network configuration/Wireless#Rfkill caveat - ArchLinux Wiki
Many laptops have a hardware button (or switch) to turn off wireless card, however, the card can also be blocked by kernel. This can be changed using rfkill. To show the current of your Wi-Fi:
~$ rfkill list 0: phy0: wlan Soft blocked: no Hard blocked: no
If the card is hard-blocked, use the hardware button or switch to unblock it. If the card is not hard-blocked but soft-blocked, use the following command:
# rfkill unblock wifi