Home
Gregory Toomey | Thursday, 09 September 2010
Main Menu
 Home
 Perl
 Resume
 Contact

 
 
 
HOWTO - Installing cheap wifi on linux   PDF  Print  E-mail 
Image This is a brief howto on adding wifi to a laptop or desktop using a cheap, common 802.11b device. For SuSE 9.1 its just about all done for you; other distributions may need to do more work.

This HOWTO

  • is for the most common wifi devices, which use the Prism2 chipset (802.11b, 11MB/sec) - compatible devices are listed here http://www.linux-wlan.org/docs/wlan_adapters.html.gz
  • is tested with a Netgear MA111; this is a usb device with a usb extension cable; can be easily connected to a laptop or desktop; they retail in Australia for about $A80
  • is for connecting from linux TO an access point using a static IP

This HOWTO is NOT

  • for 802.11g devices (different driver)
  • for peer-peer connections, or using the device AS an access point
  • for dhcp (though it should be easy to do)
  • for operating in promiscuous mode

Note:

  • iwconfig can be used to show the device status, but not for configuration
  • to configure the device you need the wlanctl-ng command
  • wlanctl-ng is documented at http://www.linux-wlan.org/

SuSE 9.1

Its trivial; the prism2 driver is loaded automatically with the default install. wlanctl-ng is available as root. Just connect the device and run script 1 or script 2.

Mandrake 10

You need to install the 'prism2_utils' package (CD 4 of Mandrake 10).

Other Distributions

For other distributions you may need to install a package to get wlanctl-ng. I recommend a 2.6 kernel as it has better wifi support.

SCRIPT 1 - simple wifi (no encryption)

You will need: an access point, ssid for the access point, a linux box, a prism2 wifi device connected to the linux box; root access. In this script I set up tbe prism2 device connect to an access point. Set up the access point to the same ssid as the script.
#!/bin/bash

modprobe prism2_usb prism2_doreset=1
wlanctl-ng wlan0 lnxreq_ifstate ifstate=enable
wlanctl-ng wlan0 lnxreq_autojoin ssid=gmtnet authtype=opensystem
# set up my IP 
ifconfig wlan0  192.168.2.6
If all is well ifconfig & iwconfig should show the device:
linux:~/bin # ifconfig
wlan0     Link encap:Ethernet  HWaddr 00:09:5B:91:E9:69
          inet addr:192.168.2.3  Bcast:192.168.2.255  Mask:255.255.255.0
          inet6 addr: fe80::209:5bff:fe91:e969/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:24495 errors:0 dropped:0 overruns:0 frame:0
          TX packets:26005 errors:0 dropped:4 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:13410263 (12.7 Mb)  TX bytes:2572436 (2.4 Mb)
linux:~/bin # iwconfig
wlan0     IEEE 802.11-b  ESSID:"gmtnet"  Nickname:"gmtnet"
          Mode:Managed  Frequency:2.412GHz  Access Point: 00:50:FC:D6:7B:A8
          Bit Rate:11Mb/s   Tx-Power:2346 dBm
          Retry min limit:8   RTS thr:off   Fragment thr:off
          Encryption key:off
          Link Quality:50/92  Signal level:-60 dBm  Noise level:-97 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0
COMMON PROBLEM:

If you ping the access point from linux and get "network unreachable", or "Tx attempt prior to association, frame dropped" in the system log, the most likely cause is the ssid in the script does not match the access point. See ftp://ftp.linux-wlan.org/pub/linux-wlan-ng/FAQ for this and other common problems

SCRIPT 2 - wifi access with encryption

Same as script 1 but with WEP encryption. The ssid and WEP key of the access point must be the same as the script. Get a random WEP key here: https://www.wireless.org.au/~jhecker/wepgen/index.php
#!/bin/bash

ssid=gmtnet
wep="E2:74:5D:35:00"

modprobe prism2_usb prism2_doreset=1
wlanctl-ng wlan0 lnxreq_ifstate ifstate=enable

wlanctl-ng wlan0 lnxreq_hostwep decrypt=true encrypt=true
wlanctl-ng wlan0 dot11req_mibset mibattribute=dot11WEPDefaultKeyID=0
wlanctl-ng wlan0 dot11req_mibset mibattribute=dot11ExcludeUnencrypted=true
wlanctl-ng wlan0 dot11req_mibset mibattribute=dot11PrivacyInvoked=true
wlanctl-ng wlan0 dot11req_mibset mibattribute=dot11WEPDefaultKey0=$wep

wlanctl-ng wlan0 lnxreq_autojoin ssid=$ssid authtype="sharedkey"

# set up my IP 
ifconfig wlan0 192.168.2.3 netmask 255.255.255.0
route add default gw 192.168.2.20

Additional Reading

The prism2 driver: http://linux-wlan.org/
Overview of Linux wireless LAN devices http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Linux.Wireless.drivers.802.11b.html