https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&user=Strfry&feedformat=atomAlpine Linux - User contributions [en]2024-03-19T04:42:03ZUser contributionsMediaWiki 1.40.0https://wiki.alpinelinux.org/w/index.php?title=Wi-Fi&diff=15231Wi-Fi2018-04-02T06:31:02Z<p>Strfry: Launching udhcpc through wpa_cli actions</p>
<hr />
<div>This document describes how to set up a wireless network connection with WPA encryption.<br />
<br />
== Install necessary drivers and software ==<br />
<br />
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]].)<br />
<br />
Install {{Pkg|wireless-tools}} and {{Pkg|wpa_supplicant}}.<br />
{{Cmd|apk add wireless-tools wpa_supplicant}}<br />
<br />
== Manual Configuration ==<br />
<br />
Bring the link up so we can look for wireless networks. (An error here means you probably need extra drivers/firmware.)<br />
{{Cmd|ip link set wlan0 up}}<br />
<br />
Find a network to connect to. Look for the ESSID. In this example we will use the ESSID "MyNet".<br />
{{Cmd|iwlist wlan0 scanning}}<br />
<br />
Configure the wlan0 interface to associate with the MyNet ESSID:<br />
{{Cmd|iwconfig wlan0 essid MyNet}}<br />
<br />
Print its configuration, to check:<br />
{{Cmd|iwconfig wlan0}}<br />
<br />
Create a wpa_supplicant configuration stanza for wpa_supplicant by executing the following:<br />
{{Cmd|wpa_passphrase MyNet > wpa.conf}} <br />
<br />
wpa_passphrase expects the password to be passed via stdin. <br />
<br />
So, type the password and press ENTER.<br />
<br />
The above commands creates the file {{Path|wpa.conf}} which includes the pre-shared key. <br />
<br />
From one terminal/console, start wpa_supplicant with the generated config:<br />
{{Cmd|wpa_supplicant -Dwext -iwlan0 -c ./wpa.conf}}<br />
<br />
From another terminal/console, start dhcpcd:<br />
{{Cmd|udhcpc -i wlan0}}<br />
<br />
The wlan0 interface should be configured with an IP address at this point:<br />
{{Cmd|ifconfig wlan0}}<br />
<br />
== Automatic Configuration on System Boot ==<br />
<br />
Add an interface stanza for wlan0 to the file {{Path|/etc/network/interfaces}}<br />
<br />
<pre><br />
auto wlan0<br />
iface wlan0 inet dhcp<br />
</pre><br />
<br />
Create {{Path|/etc/wpa_supplicant}} if it doesn't already exist, set sane permissions and append the configuration {{Path|wpa.conf}} to {{Path|wpa_supplicant.conf}}.<br />
<br />
<pre><br />
mkdir -p /etc/wpa_supplicant<br />
chmod 750 /etc/wpa_supplicant<br />
cat wpa.conf >> /etc/wpa_supplicant/wpa_supplicant.conf<br />
</pre><br />
<br />
Test the automatic interface configuration:<br />
<br />
Bring the interface down:<br />
<br />
{{Cmd|ifconfig wlan0 down}}<br />
<br />
Manually start wpa_supplicant<br />
<br />
{{Cmd|/etc/init.d/wpa_supplicant start}}<br />
<br />
The wlan0 interface should be associated with the MyNet SSID:<br />
<br />
{{Cmd|iwconfig wlan0}}<br />
<br />
The wlan0 interface should have been assigned an IP address via DHCP:<br />
<br />
{{Cmd|ifconfig wlan0}}<br />
<br />
Configure wpa_supplicant to start automatically on boot:<br />
<br />
{{Cmd|rc-update add wpa_supplicant boot}}<br />
<br />
Reboot:<br />
<br />
{{Cmd|reboot}}<br />
<br />
Log in and check that the interface is associated with the access point:<br />
<br />
{{Cmd|iwconfig wlan0}}<br />
<br />
Check that the interface was assigned an IP address via DHCP:<br />
<br />
{{Cmd|ifconfig wlan0 {{!}} grep addr}}<br />
<br />
=== Launching udhcpc through wpa_cli actions ===<br />
<br />
With the above configuration, udhcpc will only run once at boot.<br />
If the Wifi isn't available then, or the network changes in between, it needs to be notified.<br />
This is done through the wpa_cli action script in /etc/wpa_supplicant/wpa_cli.sh<br />
<br />
{{Cmd|rc-update add wpa_cli boot}}<br />
<br />
== Broadcom Wi-Fi Chipset Users ==<br />
<br />
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. <br />
<br />
You can check if you have a Broadcom chipset by using dmesg:<br />
<br />
{{Cmd|dmesg {{!}} grep Broadcom}}<br />
<br />
First install the SDK an Git:<br />
{{Cmd|apk add alpine-sdk git}}<br />
<br />
Then git clone aports from git.alpinelinux.org.<br />
<br />
<br />
{{Cmd|git clone git://git.alpinelinux.org/aports}}<br />
<br />
Change your directory to '''aports/non-free/b43-firmware''', then build it.<br />
<br />
{{Tip|You can't be root and must be a user of the group abuild (use groupadd f.e. '''groupadd $(whoami) abuild''')}}<br />
{{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''')}}<br />
<br />
{{Cmd|abuild -r}}<br />
<br />
Install the generated packge file (it will be in ~/packages/) - make sure to pass '''--allow-untrusted'''<br />
<br />
{{Cmd|apk add --allow-untrusted ~/packages/...pkg}}<br />
<br />
Now we need fwcutter, which is executed from the firmware package:<br />
<br />
{{Cmd|apk add b43-fwcutter b43-firmware}}<br />
<br />
Now you need to use modprobe so the device will show up:<br />
<br />
{{Cmd|modprobe b43}}<br />
<br />
To automate this on startup add it to /etc/modules:<br />
<br />
{{Cmd|echo b43 >> /etc/modules}}<br />
<br />
Now continue with the normal instructions. <br />
<br />
[[Category:Networking]]</div>Strfry