Difference between revisions of "Connecting to a wireless access point"

From Alpine Linux
Jump to: navigation, search
(Created page with 'This document describes how to set up a wireless network connection with WPA encryption. First make sure your wireless drivers are loded properly. Install wireless_tools and wp...')
 
 
(48 intermediate revisions by 19 users not shown)
Line 1: Line 1:
 
This document describes how to set up a wireless network connection with WPA encryption.
 
This document describes how to set up a wireless network connection with WPA encryption.
  
First make sure your wireless drivers are loded properly.
+
== Install necessary drivers and software  ==
  
Install wireless_tools and wpa_supplicant.
+
First make sure your wireless drivers are loaded properly. (if you are using a '''Broadcom chipset''', see the [[#Broadcom_Wi-Fi_Chipset_Users|section at the bottom of this post]].)
{{Cmd|apk add wireless_tools wpa_supplicant}}
 
  
Bring the link up so we can look for wireless networks.
+
Install {{Pkg|wireless-tools}} and {{Pkg|wpa_supplicant}}, which are probably available to be installed in the base setup.
 +
{{Cmd|apk add wireless-tools wpa_supplicant}}
 +
 
 +
== Manual Configuration  ==
 +
 
 +
List your available network interfaces. If you don't see any wireless interfaces (e.g. {{Path|wlan0}}), you probably need to load and/or install drivers/firmware.
 +
{{Cmd|ip link}}
 +
 
 +
Bring up the desired interface.
 
{{Cmd|ip link set wlan0 up}}
 
{{Cmd|ip link set wlan0 up}}
  
Find a network to connect to. Look for the ESSID. In this example we will use the ESSID "MyNet"
+
{{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 [https://wiki.archlinux.org/index.php/Wireless_network_configuration#Rfkill_caveat here] for information on how to unblock your wireless radio.
 +
The base installation should have <code>busybox rfkill</code> available.}}
 +
 
 +
 
 +
Use the interface to scan for wireless access points. Make sure the ESSID you want to connect to appears here.
 
{{Cmd|iwlist wlan0 scanning}}
 
{{Cmd|iwlist wlan0 scanning}}
  
Lets set the ESSID.
+
Associate the interface with desired ESSID.
{{Cmd|iwconfig wlan0 essid MyNet}}
+
{{Cmd|iwconfig wlan0 essid ExampleWifi}}
 +
 
 +
Sanity check: the interface should be configured with {{Path|ESSID:"ExampleWifi"}}.
 +
{{Cmd|iwconfig wlan0}}
 +
 
 +
Create a wpa_supplicant configuration stanza for the wireless access point.
 +
{{Cmd|wpa_passphrase 'ExampleWifi' '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>)''
 +
 
 +
 
 +
Start wpa_supplicant in the foreground to make sure the connection succeeds.
 +
{{Cmd|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 {{Path|-B}} option.
 +
{{Cmd|wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf}}
 +
 
 +
Configure the interface with an IP address.
 +
{{Cmd|udhcpc -i wlan0}}
 +
 
 +
Sanity check: the interface should have an {{Path|inet}} address.
 +
{{Cmd|ip addr show wlan0}}
 +
 
 +
== Automatic Configuration on System Boot  ==
 +
 
 +
Add a stanza for the desired interface (e.g. {{Path|wlan0}}) to {{Path|/etc/network/interfaces}}:
 +
 
 +
<pre>
 +
auto wlan0
 +
iface wlan0 inet dhcp
 +
</pre>
 +
 
 +
Make sure {{Path|/etc/wpa_supplicant/wpa_supplicant.conf}} is the correct configuration for the wireless access point you want to connect to.
 +
 
 +
Bring the interface down.
 +
 
 +
{{Cmd|ifconfig wlan0 down}}
 +
 
 +
Manually start wpa_supplicant.
 +
 
 +
{{Cmd|/etc/init.d/wpa_supplicant start}}
 +
 
 +
If all is well (confirm with the sanity checks in [[#Manual_Configuration|Manual Configuration]]), configure wpa_supplicant to start automatically on boot.
 +
 
 +
{{Cmd|rc-update add wpa_supplicant boot}}
 +
 
 +
 
 +
=== 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:
 +
 
 +
{{Cat|/etc/wpa_supplicant/wpa_supplicant.conf|
 +
<nowiki>
 +
ap_scan=1
 +
autoscan=periodic:10
 +
disable_scan_offload=1
 +
</nowiki>
 +
}}
 +
 
 +
 
 +
{{Cmd|rc-update add wpa_cli boot}}
 +
 
 +
== Broadcom Wi-Fi Chipset Users  ==
 +
 
 +
The Broadcom chipset is quite popular among older computers. You will need to compile the firmware manually for this chipset as it is not included.
 +
 
 +
You can check if you have a Broadcom chipset by using dmesg:
 +
 
 +
{{Cmd|dmesg {{!}} grep Broadcom}}
 +
 
 +
First install the SDK and Git:
 +
{{Cmd|apk add alpine-sdk git}}
 +
 
 +
Then git clone aports from git.alpinelinux.org.
 +
 
 +
 
 +
{{Cmd|git clone git://git.alpinelinux.org/aports}}
 +
 
 +
Change your directory to '''aports/non-free/b43-firmware''', then build it.
 +
 
 +
{{Tip|You can't be root and must be a user of the group abuild (use groupadd f.e. '''addgroup $(whoami) abuild''')}}
 +
{{Tip|If this is your first time building a package you will need to generate a key for use in signing packages (use '''abuild-keygen -a -i''')}}
 +
 
 +
{{Cmd|abuild -r}}
 +
 
 +
Install the generated packge file (it will be in ~/packages/) - make sure to pass '''--allow-untrusted'''
 +
 
 +
{{Cmd|apk add --allow-untrusted ~/packages/...pkg}}
 +
 
 +
Now we need fwcutter, which is executed from the firmware package:
 +
 
 +
{{Cmd|apk add b43-fwcutter b43-firmware}}
 +
 
 +
Now you need to use modprobe so the device will show up:
 +
 
 +
{{Cmd|modprobe b43}}
  
We need to create a shared key for wpa_supplicant.
+
To automate this on startup add it to /etc/modules:
{{Cmd|wpa_passphrase MyNet > wpa.conf}}
 
It will wait for the password from stdin. Enter the password and enter. Now you will have a wpa.conf file with the preshared key.
 
  
start wpa_supplicant with the generated config
+
{{Cmd|echo b43 >> /etc/modules}}
{{Cmd|wpa_supplicant -Dwext -iwlan0 -c ./wpa.conf}}
 
  
From another console, start dhcpcd
+
Now continue with the normal instructions.
{{Cmd|dhcpcd wlan0}}
 
  
You should get an IP address
+
[[Category:Networking]]

Latest revision as of 15:11, 6 October 2021

This document describes how to set up a wireless network connection with WPA encryption.

Install necessary drivers and software

First make sure your wireless drivers are loaded properly. (if you are using a Broadcom chipset, see the section at the bottom of this post.)

Install wireless-tools and wpa_supplicant, which are probably available to be installed in the base setup.

apk add wireless-tools wpa_supplicant

Manual Configuration

List your available network interfaces. If you don't see any wireless interfaces (e.g. wlan0), you probably need to load and/or install drivers/firmware.

ip link

Bring up the desired interface.

ip link set wlan0 up

Note: If this errors with ioctl 0x8914 failed: No error information, that's busybox ip's way of saying your wireless radio is rfkill'd. See here for information on how to unblock your wireless radio. The base installation should have busybox rfkill available.


Use the interface to scan for wireless access points. Make sure the ESSID you want to connect to appears here.

iwlist wlan0 scanning

Associate the interface with desired ESSID.

iwconfig wlan0 essid ExampleWifi

Sanity check: the interface should be configured with ESSID:"ExampleWifi".

iwconfig wlan0

Create a wpa_supplicant configuration stanza for the wireless access point.

wpa_passphrase 'ExampleWifi' '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 an inet address.

ip addr show wlan0

Automatic Configuration on System Boot

Add a stanza for the desired interface (e.g. wlan0) to /etc/network/interfaces:

auto wlan0
iface wlan0 inet dhcp

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.

ifconfig wlan0 down

Manually start wpa_supplicant.

/etc/init.d/wpa_supplicant start

If all is well (confirm with the sanity checks in Manual Configuration), configure wpa_supplicant to start automatically on boot.

rc-update add wpa_supplicant boot


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

ap_scan=1 autoscan=periodic:10 disable_scan_offload=1


rc-update add wpa_cli boot

Broadcom Wi-Fi Chipset Users

The Broadcom chipset is quite popular among older computers. You will need to compile the firmware manually for this chipset as it is not included.

You can check if you have a Broadcom chipset by using dmesg:

dmesg | grep Broadcom

First install the SDK and Git:

apk add alpine-sdk git

Then git clone aports from git.alpinelinux.org.


git clone git://git.alpinelinux.org/aports

Change your directory to aports/non-free/b43-firmware, then build it.

Tip: You can't be root and must be a user of the group abuild (use groupadd f.e. addgroup $(whoami) abuild)
Tip: If this is your first time building a package you will need to generate a key for use in signing packages (use abuild-keygen -a -i)

abuild -r

Install the generated packge file (it will be in ~/packages/) - make sure to pass --allow-untrusted

apk add --allow-untrusted ~/packages/...pkg

Now we need fwcutter, which is executed from the firmware package:

apk add b43-fwcutter b43-firmware

Now you need to use modprobe so the device will show up:

modprobe b43

To automate this on startup add it to /etc/modules:

echo b43 >> /etc/modules

Now continue with the normal instructions.