Ndiswrapper and Debian

Introduction

These notes describe setting up a Linksys Wireless network card on a Debian machine. Because it uses the ndiswrapper interface, the process should be generally applicable to many other cards too.

Ndiswrapper is a module that uses Windows XP wireless card drivers and wraps them with a Linux-friendly interface. Clever. And it pretty much works too, although features such as link quality reporting are missing: not ndiswrapper's fault apparently. Of course, the XP drivers are probably not Open Source or free or anything nice like that.

Physical Installation

Like any PCI card, a wireless card must of course be firmly installed. I found that detection of the card was randomly failing: lspci would sometimes report the correct card, and sometimes fail to recognize it at all. Fiddling with the motherboard mounting in the case solved that.

So, with the card in place, lspci reports (among other things):

0000:00:08.0 Network controller: Broadcom Corporation BCM4306 802.11b/g Wireless LAN Controller (rev 03)

which looks correct.

Installing Ndiswrapper

Ndiswrapper is a kernel module. The professional way to install it would be to download the source code and compile it along with a custom kernel. The easy way is to just get a couple of packages. In Sarge, these are currently:

kernel-image-2.6.8-2-386
ndiswrapper-modules-2.6.8-2-386
ndiswrapper-utils

Note that the version numbers must match. If there isn't a version of ndiswrapper-modules available for your chosen kernel-image, then you'll have to resort to the professional method.

Install those three packages and reboot with the new kernel (if you use Grub, the new kernel is selected automatically).

===== For Debian based distributions ====

Add the following line to your /etc/apt/sources.list

deb http://ndiswrapper.sourceforge.net/debian ./

... then make sure apt-get knows about it.

 1. apt-get update

What follows next is a means to install the userspace ndiswrapper programs, as well as the kernel modules. If you're using a stock Debian kernel, then chances are you can do:

 1. aptitude install ndiswrapper-utils ndiswrapper-$(uname -r) wireless-tools

==== Non-Debian Installation =====

Download, Compile and install:

Download the latest source package from...

http://ndiswrapper.sourceforge.net

Unpack the source package...

$ tar xzvf ndiswrapper-<version>.tar.gz
$ cd ndiswrapper-<version>
$ make
$ sudo make install

Getting the hardware-specific XP driver

Googling for the Broadcom BCM4306 located the Windows XP driver (sorry, I've forgotten where I got it from now). It came as file bcmwl5.zip. Unzip this in a suitable place, to find it contains:

bcm43xx.cat
bcmwl5.inf
bcmwl5.sys

Now that ndiswrapper is installed we need to identify and add the windows XP driver either from cd or from

http://ndiswrapper.sourceforge.net

identify the chip on the wireless card,

(lspci is a utility for displaying information about all PCI buses in the system and all devices connected to them)

Using lspci we can see the list of PCI components:

0000:02:03.0 Network controller: Broadcom Corporation BCM4306 802.11b/g Wireless LAN Controller (rev 02)

Make a note of the PCI vendor and device code number next to the installed wireless card

lspci -n shows PCI vendor and device codes as numbers instead of looking them up in the PCI ID database.

0000:02:03.0 0280: 14e4:4320 (rev 02)

Note the fccid number next to the previous noted PCI vendor and device codes number. Enter this code number on ndis web device list page

http://ndiswrapper.sourceforge.net/mediawiki/index.php/List

Example:

Card: Broadcom BCM4306 802.11b/g Wireless LAN Controller Laptop: HP Pavilion ze4900

 * Chipset: Broadcom 4306
 * pciid: 14e4:4320 (rev 03)
 * Driver: Broadcom WLAN Network Driver[24] 
(http://h10025.www1.hp.com/ewfrf/wc/softwareDownloadIndex?dlc=en&lc=en&os=228&product=433741&lang=en&cc=us&softwareitem=ob-26984-1) or bcmwl5.sys on Application/Driver Recovery DVD provided with laptop
 * Other: I installed this driver on Fedora Core 3 with the 4K stack (no problems thus far) and ndiswrapper-1.1. The installation worked exactly as the Installation notes says it should. 

Download the most appropriate driver and unpack

Configuring Ndiswrapper

This is well documented on the ndiswrapper website and in the package docs. Briefly, to tell ndiswrapper about the driver for your card, run (as root):

 1. ndiswrapper -i /path/to/driver/bcmwl5.inf

It responds by saying Installing bcmwl5, and creates a folder called /etc/ndiswrapper/bcmwl5 which includes files bcmwl5.inf and bcmwl5.sys. You shouldn't need the copies that you unzipped again.

Then run (as root):

# ndiswrapper -m

... to create an alias for wlan0 to point to the ndiswrapper module. Now when you access interface wlan0 for the first time, the ndiswrapper module will be automatically loaded.

 Verify the installation of the Windows driver... 

# ndiswrapper -l

Is the ndiswrapper module loaded?

 1. lsmod | grep -i ndiswrapper
<username> ndiswrapper           115184  0
<username> usbcore               119012  5 ndiswrapper,ehci_hcd,uhci_hcd

If it isn't then as root:

# modprobe ndiswrapper

Verify device recognition by NDIS Wrapper...

$ dmesg

ndiswrapper version 0.8-rc2 loaded
ndiswrapper adding bcmwl5.sys
divert: allocating divert_blk for wlan0
wlan0: ndiswrapper ethernet device 00:0d:31:35:bf:d9
using driver bcmwl5.sys

or new dmesg after upgrading from ndiswrapper 0.8 to 0.11

$ dmesg

ndiswrapper version 1.1 loaded (preempt=yes,smp=no)
ndiswrapper: driver bcmwl5 (Broadcom,06/13/2003, 3.20.23.0) loaded
PCI: Found IRQ 11 for device 0000:02:03.0
PCI: Sharing IRQ 11 with 0000:00:1f.5
PCI: Sharing IRQ 11 with 0000:00:1f.6
ndiswrapper: using irq 11
wlan0: ndiswrapper ethernet device 00:50:4g:71:38:1b using driver bcmwl5, configuration file 14E4:4320.5.conf
wlan0: encryption modes supported: WEP, WPA with TKIP, WPA with AES/CCMP
wlan0: no IPv6 routers present
on some laptops it may be necessary to press a function key eg Fn + F2 to enable wirelless in the bios

Manual configuration of wlan0

To make sure things are working, run the following commands (as root) to configure the network interface:

 1. modprobe wlan0

should respond with encouraging messages such as:

{{{
    ACPI: PCI interrupt 0000:00:08.0[A] -> GSI 19 (level, low) -> IRQ 185
    ndiswrapper: using irq 185
    wlan0: ndiswrapper ethernet device 00:xx:xx:xx:xx:xx using driver bcmwl5, configuration file 14E4:4320:1737:0013.5.conf
    wlan0: encryption modes supported: WEP, WPA with TKIP, WPA with AES/CCMP

}}}

Then, use iwconfig (part of Debian's wireless-tools package) to set up your network with the settings that your wireless router requires:

 1. iwconfig wlan0 essid myssid
 1. iwconfig wlan0 mode managed 

Confirm it by typing iwconfig on its own and checking the output. If the ESSID value isn't shown, then the wireless adaptor has failed to authenticate itself with the router.

Finally, get an IP address either via DHCP or manually, and set up a default route. I did:

 1. ifconfig wlan0 192.168.1.204 netmask 255.255.255.0
 1. route add default gateway 192.168.1.1 wlan0

And with luck, it's working! Check by pinging something. You'll also need some DNS servers set up in /etc/resolv.conf in just the same way as for a wired network.

Typical List of Commands to Manually Connect to a Network Using DHCP

 1. modprobe ndiswrapper
 1. iwconfig wlano mode managed
 1. iwconfig wlan0 essid Magic_Word
 1. iwconfig wlan0 key MAGIC_NUMBER (if using Wep encription)
 1. dhclient wlan0

Advanced manual setup

Create the wlan0 configuration file using your favourite text editor...call it wlan0start.sh for instance enter the following lines adding details as required:

modprobe ndiswrapper
iwconfig wlano mode managed
iwconfig wlan0 essid Magic_Word
iwconfig wlan0 key MAGIC_NUMBER (if using Wep encription)
dhclient wlan0

Automatic configuration

Debian uses the ifup and ifdown commands, which are configured by files in /etc/network/, for controlling network interfaces. The wireless-tools package adds features to this mechanism for setting the wireless parameters automatically.

The relevant bit in /etc/network/interfaces looks like this for my system:

{{{
    auto wlan0
    iface wlan0 inet dhcp
        wireless_mode managed
        wireless_essid myssid

or if you don't like DHCP:

    auto wlan0
    iface wlan1 inet static
        address 192.168.1.204
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.1
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 212.159.13.49 212.159.11.150
        # wireless_ options are implemented by the wireless-tools package
        # NOTE the use of an underscore, and no quotes around the parameters
        wireless_mode managed
        wireless_essid myssid

I struggled with this for ages, until I realised that a made a few typos: 'wireless_essid' has an underscore, and not a hyphen; and the 'myssid' does NOT have quotes around it (I was confused because iwconfig shows it with quotes). }}}

Troubleshooting Tips

Ensure correct version of ndiswrapper is compatible with kernel version.

if driver trouble, remove driver with

# rm -fr /etc/ndiswrapper/<drivername>

then reinstall driver

if module needs to be removed

 1. rmmod ndiswrapper

reload driver

 1. modprobe ndiswrapper

=== other useful connection testing commands ===

Scan for other wireless devices $ iwlist wlan0 scan this should list what your wireless card can see.

$ /sbin/iwconfig wlan0

or

$ /sbin/ifconfig wlan0

=== That's it! ===

Except that you probably ought to use to WEP or WPA encryption on your network. WEP can be done by adding a line in /etc/network/interfaces -- see the wireless-tools documentation. And there's something called wpasupplicant for using WPA, but I haven't tried that. If you want to be able to use multiple WLANs, there are a few tools for switching between them. A popular one is Wifi Radar, a GUI tool that allow easy configuration of multiple WLANs.


I hope that makes sense; let me (ChrisDennis) know if not. As ever, please add to or correct this page as you see fit.

I (IanBrazier) have added some useful commands to help newbies or for general fault diagnosis

LinuxHints/Ndiswrapper And Debian (last edited 2006-05-09 17:47:54 by 84)