WPA2 Wireless With Linux

This is a simple tutorial produced by me and my good mate enigma. It is aimed at Gentoo and uses the Broadcom drivers but this should replicate to other systems.

The first step is to get your drivers and for Broadcom, which is relatively easy as they produce them for us. So first download the driver (these drivers support BM4311-, BCM4312-, BCM4321-, and BCM4322-based cards) and was also successful in this case with BCM4328.

Check that the package ‘linux-headers’ is installed, this is really just for completeness sakes. Gentoo would not work for long without this package!(gentoo)# emerge linux-headers
... output ...

Unpack the downloaded drivers and build for your current kernel:
(gentoo)# tar -xzf hybrid-portsrc-ARCH-VERSION.tar.gz
(gentoo)# make -C /lib/modules/`uname -r`/build M=`pwd`
... output ...

Remove any existing wireless drivers.
(gentoo)# rmmod ndiswrapper b43 ssb bcm43xx b43legacy

Add in some modules required for WPA wireless:
(gentoo)# modprobe ieee80211_crypt_tkip

Test the newly built wireless driver:
(gentoo)# insmod wl.ko
(gentoo)# iwconfig
.. output ...
(gentoo)# iwlist scanning
... output ...

If that is working we can copy in the driver to the kernel and add to the autoload:
(gentoo)# cp wl.ko /lib/modules/`uname-r`/kernel/net/wireless/
(gentoo)# rmmod wl
(gentoo)# modprobe wl
(gentoo)# echo 'wl' >>/etc/modules.autoload.d/kernel-2.6

So now we have a working driver we can go on to configure for WPA. Alter the /etc/conf.d/net (note we assume that eth0 is wireless):
# Prefer wpa_supplicant over wireless-tools
modules=( "wpa_supplicant" )
# It's important that we tell wpa_supplicant which driver we should
# be using as it's not very good at guessing yet
wpa_supplicant_eth0="-Dmadwifi"

Next set up the network in the /etc/wpa_supplicant/wpa_supplicant.conf:
# This setting is required or the connection will not work
ctrl_interface=/var/run/wpa_supplicant
# Ensure that only root can read the WPA configuration
ctrl_interface_group=0
# Let wpa_supplicant take care of scanning and AP selection
ap_scan=1
# Only WPA-PSK is used. Any valid cipher combination is accepted
network={
ssid="example"
proto=WPA RSN # RSN is needed for WPA2
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP WEP104 WEP40
psk=06b4be19da289f475aa46a33cb793029d4ab3db7a23ee92382eb0106c72ac7bb
#The higher the priority the faster it connects
priority=2
}

And that is it, you should find that your wireless is enabled on boot.
Thanks should also go to DJ Kaos for the preparation of the driver.

Leave a Reply

Your email address will not be published. Required fields are marked *