Netgear WG111T with WPA-SDK on Debian 4.0 (Etch)

Introduction

This document describes how to get a Netgear WG111T USB Wireless Adaptor working under Debian 4.0 (Etch) using WPA-PSK as the secure wireless protocol.

'ndiswrapper' is used to wrap Netgear's binaries to provide the driver interface for Linux. 'wpa_supplicant' is used to negotiate the WPA-PSK authentication.

The examples use aptitude rather than apt-get. You can probably substitute the apt-get command wherever aptitude is used to install packages, as the syntax should be the same.

The examples assume you use 'sudo' to execute commands as root. If you don't, just execute the command as the root user without the 'sudo' command.

Installation

Getting the Netgear Driver

Download the driver from Netgear site. I used version 1.3 on the basis that from the release notes, version 2.0 and 2.1 don't appear to add anything other than Windows Vista support. Version 1.2 did not work for me using WPA-PSK. The release notes for 1.3 state it adds support for WPA2-PSK.

http://kbserver.netgear.com/products/WG111T.asp

Unfortunately, version 1.3 is distributed as an InstallShield executable from which we need to extract the drivers.

Extracting Drivers

Use 7zip to extract the first level of files from the EXE

   $ sudo aptitude install pz7ip-full
   $ 7z -o/tmp/WG111T e ~/Desktop/wg111t_1_3_setup.exe

This will extract the EXE contents to /tmp/WG111T

Unpacking the CAB Files

I successfully unpacked the CAB files, using unshield (installed from Debian 4.0 (Etch)) available from http://www.synce.org/ or http://synce.sf.net/

The EXE contained two CAB files and one with an .hdr extension. With these in the working directory, the following command will extract the contents of both data1.cab and data2.cab into a new sub-directory called 'Disk1':

$ unshield -d Disk1 x data1.cab

Installing ndiswrapper

A more recent version of the ndiswrapper package is required than the one shipped with Debian 4.0 (Etch). Therefore download version 1.53 from here.

For Debian 5.0 (Lenny) - follow the instructions at http://wiki.debian.org/NdisWrapper for setting up ndiswrapper

Installing the Linux Kernel Headers

It is best to install the linux image using 'linux-image-2.6-686' rather than 'linux-image-2.6.18-6-686' or whatever the latest stable version of the 2.6 kernel is. It always depends on the latest binary image for the 2.6 kernel. That way, the latest version is automatically upgraded. However, your setup may vary, but it is sensible to install the same corresponding linux-headers package as you have for your linux image package.

The following commands will help you decide which version of the linux-headers to install:

   $ uname -r
   $ dpkg -l 'linux-*' | egrep '^ii +linux-(image|headers)'

If linux-image-2.6-686 is listed, then install linux-headers-2.6-686, otherwise install the version provided by 'uname -r', e.g. linux-image-2.6.18-6-686.

   $ sudo aptitude install linux-headers-2.6-686 build-essential

Building ndiswrapper from Source

It is best to always build local packages under /usr/local/src for consistency. You will need write access to this directory as an ordinary user. On Debian it's best achieved by adding yourself to the 'staff' group.

Extract the downloaded tar file (as above):

   $ cd /usr/local/src
   $ tar zxvf ndiswrapper-1.53.tar.gz
   $ cd ndiswrapper-1.53 
   $ make
   $ sudo make install

Configuring ndiswrapper

Find the location of netwg11t.inf amongst the EXE/CAB files extracted earlier. E.g.

   $ find ~/Desktop/ -iname netwg11t.inf

Change to the directory containing netwg11t.inf. In my case there were two directories containing identical files. I chose ./nt32drv/

Install the drivers using:

    $ cd ./nt32drv/
    $ sudo ndiswrapper -i netwg11t.inf

ndiswrapper will create a new directory under /etc/ndiswrapper/ containing the necessary files, in particular the required binary. You can list the available ndiswrapper drivers, which should now show netwg11t.

   $ /usr/sbin/ndiswrapper -l

Finally, install ndiswrapper as a loadable module that will be re-loaded on boot.

   $ sudo ndiswrapper -m
   $ sudo update-modules

The first command creates the file /etc/modprobe.d/ndiswrapper and the second command updates the modules configuration.

Installing WPA Supplicant

Install the wpasupplicant package:

   $ sudo aptitude install wpasupplicant

Configure WPA Supplicant

Create the initial /etc/wpasupplicant.conf file using the wpapassphrase utility. Replace $SSID and $WPA-PSK with the SSID and private shared key of the network you're connecting to.

The following method is easiest to explain, but leaves your WPA-PSK shared key in your bash history. You might like to clear the history afterwards. Alternatively, use the second method.

Method 1.

   $ cd ~/tmp
   $ wpa_passphrase $SSID $WPA-PSK >wpa_supplicant.conf

or

Method 2.

   $ cd ~/tmp
   $ wpa_passphrase $SSID >wpa_supplicant.conf

wpa_passphrase will prompt for input from stdin. Type the passphrase and hit the 'enter' key.

Both Methods

Open the file with your favourite editor and update it to be similar to the following:

ctrl_interface=/var/run/wpa_supplicant

network={
        ssid="$SSID"
        key_mgmt=WPA-PSK
        #proto=WPA
        #pairwise=TKIP
        #group=TKIP
        #psk="$WPA-PSK"
        psk=**************************
        #scan_ssid=1

'proto', 'pairwise', 'group' and 'scanssid' have been commented out, as it should not be necessary to specify them. However, these settings may be useful to consider depending on the network you are connecting to. The following man pages will be helpful if these settings don't work out-of-the-box. In particular, /usr/share/doc/wpasupplicant/examples/README.wpasupplicant.conf.gz describes what these configuration options do.

   $ man wpa_supplicant
   $ man wpa_supplicant.conf
   $ less /usr/share/doc/wpasupplicant/README.Debian
   $ gunzip -c /usr/share/doc/wpasupplicant/README.gz | less
   $ ls /usr/share/doc/wpasupplicant/examples/
   $ gunzip -c /usr/share/doc/wpasupplicant/examples/README.wpa_supplicant.conf.gz | less
   $

The man pages for wpa_supplicant include a useful 'QUICK START' section.

Move the configuration file to /etc/

   $ sudo mv ~/tmp/wpa_supplicant.conf /etc/
   $ sudo chown root.root /etc/wpa_supplicant.conf
   $ sudo chmod 640 root.root /etc/wpa_supplicant.conf

Configuring the Network Interfaces

Update your /etc/network/interfaces file to look something like the following:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

auto wlan0
iface wlan0 inet dhcp
   wpa-driver wext
   wpa-conf /etc/wpa_supplicant.conf

The eth0 entry isn't entirely relevant, but I've left it in place for the case of an existing network card. However, the entry may cause conflicts. I had a static IP address set for my card. After booting with the network card unplugged, and wireless card inserted, the routing table had entries for eth0 stopping the network from working. Commenting out the 'auto eth0' line fixed it. Strangely, booting with the network cable inserted and USB card removed still worked, with the line still commented out. Setting eth0 to use DHCP with 'auto eth0' enabled worked fine.

The entry relating to the wireless card is 'wlan0'.

Running ndiswrapper

Plug in the Netgear WG111T USB Wireless Adaptor.

Load the ndiswrapper module:

   $ sudo modprobe ndiswrapper

The wlan0 interface should now be shown using iwconfig:

   $ sudo iwconfig wlan0

If not, analyse the problem before going further. See the Trouble Shooting section.

Starting the Network

You should be able to start the wireless network with:

   $ sudo /etc/init.d/networking restart

However, the driver or ndiswrapper/driver/device combination are not rock solid. If it doesn't immediately work, try shutting down the PC entirely, power off and reboot.

Trouble Shooting

This section should help you analyse why your wireless connection isn't working. It's by no means exhaustive, but hopefully, helpful. The sub-sections are intended to be in a logical analytical order, so you should work through them in sequential order.

ndiswrapper

To isolate problems, it may be best to initially boot without the device inserted.

Check the ndiswrapper module is loaded:

   $ sudo lsmod | grep ndiswrapper

It should have been loaded on startup. If not, re-run the commands to cause it to be loaded on startup and then manually load it:

   $ sudo ndiswrapper -m
   $ cat /etc/modprobe.d/ndiswrapper
   $ update-modules
   $ sudo modprobe ndiswrapper

Check log files and the output of for any error messages:

   $ dmesg

If you want to unload the module in the future:

   $ sudo rmmod ndiswrapper

After unloading the module, you should then be able to remove the USB device. Try removing the device and re-inserting it after at least a few seconds. Then reload the ndiswrapper module.

After inserting the USB Wireless Adaptor and having loaded the ndiswrapper module, either before or after inserting the device, the wlan0 entry should be listed by iwconfig.

   $ sudo iwconfig

At this stage we haven't negotitated access to the wireless access point, so ESSID will show as 'off/any'.

WPA Supplicant

Firstly make sure wpa_supplicant not running as a daemon process:

   $ ps aux | grep wpa_supplicant

If it is, kill it:

   $ sudo killall wpa_supplicant

Note: 'wext' is the correct device to use in modern kernels, not 'ndiswrapper'. See /usr/share/doc/wpasupplicant/README.Debian. The wireless extension value in the WE column of the output of the following command should be 18 or higher. It is 20 on my setup.

   $ cat /proc/net/wireless

Run wpa_supplicant from the command line, in foreground mode, with debug turned on:

   $ sudo wpa_supplicant -c/etc/wpa_supplicant.conf -iwlan0 -Dwext -d

This should result in ifconfig showing the wlan0 device, but as yet, we won't have access to the network. Leave wpa_supplicant running in the foreground for now.

Start the network:

   $ sudo ifup wlan0

The network should now be up. Check that an IP address is shown under 'inet addr' in the wlan0 section of the output of the following command:

   $ /sbin/ifconfig wlan0

Check the output of 'iwconfig'.

   $ /sbin/iwconfig

The 'ESSID' entry in the wlan0 section should be showing the SSID of the access point you are trying to connect to. Additionally, the 'Access Point' entry should be displaying a MAC address.

If the interface hasn't been configured, check whether your access point is configured to only allow specific MAC addresses to connect to the network.

Otherwise, if all is working, stop the network:

   $ sudo ifdown wlan0

Then press Ctrl-C in the shell running wpa_supplicant in the foreground, if it is still running. It probably exited after the 'ifup' command.

Restart the network using the network init script, which will run wpa_supplicant in the background as a daemon process.

   $ sudo /etc/init.d/networking restart

Network

If the network's still not working, check your firewall's not blocking your attempts to access the Internet. Check the firewall's log output. The wireless device is not the same device as your network card. The rules may be device specific.

Check the output of /sbin/ifconfig. It should be showing an IP address (assigned using DHCP) under 'inet addr' in the wlan0 section.

Trying pinging the IP address of your router.

   $ ping $ROUTER_IP

If ip addresses appear to work, but names are not resolved, check the contents of /etc/resolv.conf it should specify a nameserver.

Check the routing table. In most situations, it should just have two entries, each for the wlan0 interface.

   $ /sbin/route -n

It should look something like this:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.10.0    0.0.0.0        255.255.255.0   U     0      0        0 wlan0
0.0.0.0         192.168.10.1   0.0.0.0         UG    0      0        0 wlan0

If other interfaces are listed, they may be routing requests to the wrong, maybe non-existant, interface.

Resources

-- Frank Dean - 18 Jan 2009