Wireless networking using the ndiswrapper module

Posted by Steve on Fri 2 Jun 2006 at 12:35

Getting wireless networking working with the ndiswrapper driver is fairly straightfoward if your card has an associated Windows driver. Here we'll look at getting wireless networking working for a Dell Inspiron 1300, you should be able to follow the recipe for most other wireless networking cards which are supported ndiswrapper.

ndiswrapper is a collection of utilities which essentially allows you to load and run a network card driver written for Microsoft Windows upon your Linux kernel. This means that a card which isn't supported natively may be used indirectly.

Note:

Running ndiswrapper isn't recommended unless it is the only means you have of using your wireless card, since it allows potentially buggy Windows driver code to interfere with your Linux kernel.

I've been given a Dell Inspiron 1300 laptop and discovered that the wireless network card isn't supported by the Linux kernel. Mostly this isn't a big deal, but it would be nice to be able to surf wirelessly on trains, and in bed.

Enter ndiswrapper! It turns out that there is a Windows driver which can be used to make this card work, and installing that driver is very straightfoward.

Since ndiswrapper isn't included in the stock kernels we have to build it seperately with the module-assistant package.

First of all we'll need to install the module-assistant package, and then prepare the build environment. (This means downloading the Kernel headers which match your currently running kernel):

root@steve:~# apt-get install module-assistant

Once installed the preparation is carried out by running "module-assistant prepare". (You can use m-a as a shortcut for module-assistant. I'll type the longer version in these examples.)

root@steve:~# module-assistant prepare
Getting source for kernel version: 2.6.16-2-xen-686
apt-get install linux-headers-2.6.16-2-xen-686
Reading package lists... Done
Building dependency tree... Done
The following extra packages will be installed:
  linux-headers-2.6.16-2-xen
The following NEW packages will be installed
  linux-headers-2.6.16-2-xen linux-headers-2.6.16-2-xen-686
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 3433kB of archives.
After unpacking 28.0MB of additional disk space will be used.
Do you want to continue [Y/n]?

Here we've downloaded the Kernel header package, and setup the symbolic link /usr/src/linux to point to the correct place.

Now that the module assistant configuration is complete we need to get the ndiswrapper kernel modules source code:

root@steve:~# apt-get install ndiswrapper-source

Build the module by executing:

root@steve:~# module-assistant build ndiswrapper

If there are no errors you should be ready to install the relevent tools:

root@steve:~# apt-get install ndiswrapper-utils-1.8

With the tools installed we can now install our freshly built module package:

root@steve:~# module-assistant install ndiswrapper
Selecting previously deselected package ndiswrapper-modules-2.6.16-2-xen-686.
(Reading database ... 68278 files and directories currently installed.)
Unpacking ndiswrapper-modules-2.6.16-2-xen-686 (from .../ndiswrapper-modules-2.6.16-2-xen-686_1.16-1+2.6.16-14_i386.deb) ...
Setting up ndiswrapper-modules-2.6.16-2-xen-686 (1.16-1+2.6.16-14) ...

Before installing your new kernel module you'll need to download and install the Windows Device Driver. In my case I could fetch these by running:

root@steve:~# wget http://biginoz.free.fr/linux/bcmwl5.sys
root@steve:~# wget http://biginoz.free.fr/linux/bcmwl5a.inf

Download your drivers from wherever you can find them, or from your CD-ROMs. With the drivers downloaded you can configure ndiswrapper to use them by running:

root@steve:~# ndiswrapper -i bcmwl5a.inf
Installing bcmwl5a
Forcing parameter IBSSGMode|0 to IBSSGMode|2
Forcing parameter IBSSGMode|0 to IBSSGMode|2

At this point we're almost completely finished. We just need to load the kernel module we built. (Loading it before installing a driver will fail):

root@steve:~# depmod -a
root@steve:~# modprobe ndiswrapper

All being well you should now have a wireless network interface:

root@steve:~# ifconfig wlan0 up

If you, your neighbours, or your train company, have no security you can now get an IP address:

root@steve:~# dhclient wlan0
Internet Software Consortium DHCP Client 2.0pl5
Copyright 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.
All rights reserved.

Please contribute if you find this software useful.
For info, please visit http://www.isc.org/dhcp-contrib.html

sit0: unknown hardware address type 776
sit0: unknown hardware address type 776
Listening on LPF/wlan0/00:16:ce:32:57:67
Sending on   LPF/wlan0/00:16:ce:32:57:67
Sending on   Socket/fallback/fallback-net
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPACK from 192.168.0.1
bound to 192.168.0.9 -- renewal in 43200 seconds.

If you're using WEP encryption you can use something like the following to configure it:

iwconfig wlan0 key open 1234abcd56
iwconfig wlan0 essid my_essid_name
dhclient wlan0

(iwconfig is contained in the wireless-tools package.)

(Note: TCP over DNS works fine on British Rail trains ;)


This article can be found online at the Debian Administration website at the following bookmarkable URL:

This article is copyright 2006 Steve - please ask for permission to republish or translate.