Monday, 14 April 2008

Setting up Netgear wireless adapters in Ubuntu

I recently decided I should really start using Linux properly, at least at home. I went for Ubuntu, which from what I can tell is one of the most popular distributions. The version I'm using is 7.10 (Gutsy Gibbon).

Unfortunately I found that my Netgear WG111 USB wireless adapter was not currently supported on Linux, and I had to jump through a few hoops to get online. I've decided to document the process I went through to set this up. I learned a lot about Linux in a very short space of time by doing this and I'll detail what I learned here. Hopefully others will be able to make use of this.

N.b. The Ubuntu forums were a great deal of help, most of the information here was learned from there, in particular the post "Installing a Netgear WG111v3 or other similar wireless" by stooshbunutu.

The adapter I have is a WG111v3, although I believe this should work for other versions as well as other Netgear wireless adapters such as the WG311 PCI card and WG511 PC card/PCMCIA adapter by downloading the relevant .inf files (see below).

N.b. It's definitely worth checking that your Ubuntu Live CD is free of errors if you haven't already. Mine turned out to be corrupted, despite the fact that I was initially able to install Ubuntu to hard disk without any reported problems. This caused a lot of unnecessary frustration. There is an option to check the CD in the CD's boot menu.

This is the method I used to get everything working.

Step One - Install NDISwrapper

The first thing you'll need is a tool called NDISwrapper. If you have a Windows driver for your network adapter (most do I assume), NDISwrapper allows you to use this Windows driver under Linux.

NDISwrapper is actually included with Ubuntu 7.10, but it's not installed by default. You can install it from the Synaptic Package Manager (System > Administration > Synaptic Package Manager) or by opening a terminal window and using the apt-get command. I failed to get either of these to work due to the CD corruption mentioned above, so I ended up downloading and building the latest version. Having the latest version may be advantageous anyway, and I learned a lot through doing my first Linux build, so this is the method I will detail here.

Download the NDISwrapper source code

You should be able to download the latest version by finding NDISwrapper on SourceForge. At the time of writing this was version 1.52. If like me you don't have a wired connection you'll be having to do this on another machine. If so, copy the file to your home directory (Places > Home Folder) in Ubuntu.

Open a Terminal Window

Open a terminal window (Applications > Accessories > Terminal). From here on you'll be issuing some commands that need super user privileges. To obtain these, use the following command:

sudo su

You'll probably be asked to enter your password.

N.b. If you close your terminal window and re-open it you'll probably need to issue this command again.

Install the build-essential Package

When I tried to build NDISwrapper I got a whole raft of errors and warnings. I was about ready to give up at this point, as a Linux beginner I wasn't about to try and debug someone else's source code! Curiosity got the better of me and I scrolled up to find out where the first error had occured. "Couldn't find stdlib.h". I've been a developer long enough to know that this is pretty fundamental! A bit of research and I found out you need to install the "build-essential" package to get the standard libraries. You can do this through Synaptic (System > Administration > Package Manager) or by issuing the apt-get command as follows:

apt-get install build-essential

Remove existing NDISwrapper

I'm not sure if this step is necessary, but I ran it as instructed in the forum post mentioned above. I guess the following command should uninstall any existing version:

apt-get remove ndiswrapper-common

Extract the files onto your hard disk

The file you've downloaded should be a gzipped tar file (extension tar.gz). tar combines mutiple files and directories into one file, and gzip compresses this file to make it smaller. The same operations as performed for Windows with zip files. You can use the tar command-line utility to extract the source code:

Go to your terminal window. You should be in your home directory so you can extract the source code by typing in the following command:

tar xvvf ndiswrapper-1.52.tar.gz

N.b. You may be using a newer version, in which case the file name will be different. You can use tab completion to complete the file name for you, as you start typing "ndis" try pressing the [tab] key to fill in the rest of the name.

This should have extracted the files into the ndiswrapper-version directory. Navigate into this directory using the cd command:

cd ndiswrapper-1.52

N.b. Again the version number may differ, and [tab] can help you here.

Build NDISwrapper

Hopefully now you can build NDISwrapper by issuing the make command.

make install

Step Two - Find and Set Up the Windows Driver

The next thing you'll need to do is find the Windows driver for your adapter and set it up with NDISwrapper.

Download the Windows Driver

I found the Windows driver for my WG111v3 here:

Windows drivers for other Netgear adapters should be easy to find through the Netgear Support website.

As with NDISwrapper, copy the downloaded file into your home directory and use tar to extract the files:

tar xvvf WG111v3.tar.bz2

Note that Linux is case sensitive, so in the example above you'll need to make sure the 'W' and 'G' are capitalised.

Configure NDISwrapper to use the Windows Driver

I'm now assuming the directories to which NDISwrapper and the Netgear drivers have been extracted are sat at the same level (under your home directory).

From the NDISwrapper directory, you would issue the following command in order to load the Netgear drivers (adjusting the path for different drivers):

ndiswrapper -i ../WG111/WG111v3.inf

Get Up and Running

The next bit is a bit of a mystery to me, I intend to find out what's happening and will update this post when I do! Anyway it involves issuing these commands:

depmod -a
modprobe ndiswrapper
ndiswrapper -m

Hopefully now everything should be working and you'll be able to set up your wireless network.

Step Three - Handle Rebooting

After this great success, I was dismayed when next time I booted my machine I was back to square one. I wandered off to the gym and returned determined to work out what was going on. It turns out you need to do a little more work in order to have your wireless adapter set up each time you boot into Ubuntu.

Add NDISwrapper to boot

Again I'm not sure how this bit works, but intend to elaborate as I find out:

ndiswrapper -m

Then add the line "ndiswrapper" to the the /etc/modules file which you can edit using the following command:

gedit /etc/modules

Hopefully that's it!


jay said...

hi Thanks that was very useful to me. very detailed instruction as i am a newbie to linux

James Morcom said...

Glad it's been of help to someone :)

Ethan said...

I installed Ubuntu through Wubi as an easy dual boot fix. I cannot find the preinstalled NDISwrapper orbuil-essential. The terminal command fails with the error that the file cannot be found/does not exist. Any ideas on how I can possibly download and install those?

James Morcom said...

Did you try installing them through Synaptic?

System > Administration > Synaptic Package Manager

Ethan said...

Yes, I did try going through synaptic to no prevail.

khoa said...
This comment has been removed by the author.
khoa said...

Hi James,
Thank you very much for your very detail instruction. I just installed Ubuntu 8.0.4 and followed your instruction step by step to install my Netgear wireless adapater WG311V3 using Version 1.1 driver for windows XP. It works great and successful right after I rebooted my machine. Thanks again for your instruction and the time you spent to write the instruction. I am very sure a lot of people will be benefit from your work.

TechMaddy said...

I just now got my new NetGear WG111v3. The box contained only the installation for windows. I was wondering if I could use this in Ubuntu. Your article was helpful.

Thanks a ton. :)

Adrian said...

depmod -a
modprobe ndiswrapper
ndiswrapper -m

The above lines is loading the ndiswrapper as a module in the kernel

Vikram Chauhan said...
This comment has been removed by a blog administrator.
Alex Gold said...
This comment has been removed by a blog administrator.