Wi-Fi: Difference between revisions
m (less verbose wpa_passphrase invocation. Also, should be using /etc/wpa_supplicant prefix.) |
m (improved wpa_supplicant usage) |
||
Line 28: | Line 28: | ||
{{Cmd|wpa_passphrase 'ExampleWifi' 'ExampleWifiPassword' > /etc/wpa_supplicant/wpa.conf}} | {{Cmd|wpa_passphrase 'ExampleWifi' 'ExampleWifiPassword' > /etc/wpa_supplicant/wpa.conf}} | ||
Start wpa_supplicant in the foreground to make sure the connection succeeds. | |||
{{Cmd|wpa_supplicant - | {{Cmd|wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa.conf}} | ||
If all is well, run it as a daemon in the background by passing {{Path|-B}}. | |||
{{Cmd|wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa.conf}} | |||
From another terminal/console, start dhcpcd: | From another terminal/console, start dhcpcd: |
Revision as of 06:33, 19 July 2018
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.
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 extra drivers/firmware.
ip link
Bring the desired interface up.
ip link set wlan0 up
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.conf
Start wpa_supplicant in the foreground to make sure the connection succeeds.
wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa.conf
If all is well, run it as a daemon in the background by passing -B.
wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa.conf
From another terminal/console, start dhcpcd:
udhcpc -i wlan0
The wlan0 interface should be configured with an IP address at this point:
ifconfig wlan0
Automatic Configuration on System Boot
Add an interface stanza for wlan0 to the file /etc/network/interfaces
auto wlan0 iface wlan0 inet dhcp
Create /etc/wpa_supplicant if it doesn't already exist, set sane permissions and append the configuration wpa.conf to wpa_supplicant.conf.
mkdir -p /etc/wpa_supplicant chmod 750 /etc/wpa_supplicant cat wpa.conf >> /etc/wpa_supplicant/wpa_supplicant.conf
Test the automatic interface configuration:
Bring the interface down:
ifconfig wlan0 down
Manually start wpa_supplicant
/etc/init.d/wpa_supplicant start
The wlan0 interface should be associated with the MyNet SSID:
iwconfig wlan0
The wlan0 interface should have been assigned an IP address via DHCP:
ifconfig wlan0
Configure wpa_supplicant to start automatically on boot:
rc-update add wpa_supplicant boot
Reboot:
reboot
Log in and check that the interface is associated with the access point:
iwconfig wlan0
Check that the interface was assigned an IP address via DHCP:
ifconfig wlan0 | grep addr
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
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 an 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.
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.