Installing a wireless network adapter on Ubuntu 8.10
assembly date
2009, January 27.
author(s)
Balla Marcell
keywords
- intrepid ibex
- wireless
- WPA
I was busy trying different Linux distributions the last month: Sabayon, Dreamlinux, Absolute Linux just to name a few. Eventually I turned back to Xubuntu in its newest version (8.10 - Intrepid Ibex) because I wasn't satisfied with the hardware support of the other systems.
Installing Xubuntu 8.10 is like it should be: easy and fast. After the installation completed everything seemed to work fine. Really? Everything?
Well, not exactly. It turned out that my wireless network adapter wasn't detected during the installation. Since I already tried to set it up on an earlier Xubuntu version I knew that I had to fiddle around with ndiswrapper again. Below you find a quick guide if you are facing similar problems.
Important: I strongly encourage you to get hold of a USB network adapter that has a chip, which is supported and detected by the system automatically. Otherwise you have to use "ndiswrapper" which in my case lead to a not working or very unstable wireless connection! Check out the list of supported devices on the official wireless linux wiki. If you use such a device skip all steps before the "Continue here" section below.
Suggestion: Get a ZyXEL ZyAIR G-202 wireless USB network adapter. It works perfectly out-of-the box under Xubuntu 8.10 and Windows XP.
The not automatically detected network adapter I had most success with was a Netgear MA111v2. It is a USB adapter with Microsoft Windows drivers only. The network adapter is not detected by Xubuntu, that is why you have to use ndiswrapper to set the network adapter up manually.
Note: I first tried to do the following steps with my Netgear WG311v3 PCI adapter, but failed miserabely. That card doesn't seem to work under Xubuntu 8.10! Later I tried a Belking Wireless G USB adapter, but it also failed to work.
First thing to try is to insert the Xubuntu install CD and issue the "apt-get install ndiswrapper" command. Unfortunately this doesn't work.
Why? Because ndiswrapper is not shipped with the Xubuntu 8.10 CD. Trying the same thing through Synaptic tells you that you have to have a working internet connection to install the package. Bad luck!
To install ndiswrapper on Xubuntu 8.10 you need to visit the following two sites and download the "ndiswrapper-common" and the "ndiswrapper-utils" package (you need to access the internet from another machine to do this):
- http://packages.ubuntu.com/intrepid/ndiswrapper-common
- http://packages.ubuntu.com/intrepid/ndiswrapper-utils-1.9
I used gdebi to install the packages. Start with the "ndiswrapper-common" package, because it is needed by the other one! (see Figure 1, the screenshot is taken from a different PC)
Figure 1: Installing ndiswrapper-utils using gdebi
The next thing to do is installing the Microsoft Windows driver. Let me thank "slayer" at this point, who posted very useful hints on ubuntuforums.org. The commands below are more or less a summary of what he posted there.
Insert the Netgear driver CD into your drive (see Figure 2) and open a terminal in which you enter the following commands:
Figure 2: Contents of the Netgear MA111v2 driver CD-ROM
sudo ndiswrapper -i MA111v2.inf
sudo depmod -a
sudo modprobe ndiswrapper
sudo ndiswrapper -m
In order to have ndiswrapper loaded the next time you boot the system, open the "/etc/modules" file and add an additional line containing the word "ndiswrapper" (no quotes!) at the bottom and save the file. We need this because ndiswrapper enables our network adapter by loading the network driver for Linux! Reboot the system now!
After rebooting check that ndiswrapper has loaded the driver correctly by issuing the "ndiswrapper -l" command inside a terminal. It should tell you that the driver is installed and the device is present. Do not continue if this is not the case!
Continue here: Because I find the Xubuntu Network-Manager Applet unreliable, I will describe what to do by hand in order to get your network adapter to associate with a wireless router using the WPA encryption standard.
The package named "wpasupplicant" is responsible for WPA security features under Linux. Thankfully this package is installed with Xubuntu by default. The only thing to do is to create the configuration file for it. Create a file called "wpa_supplicant.conf" in "/etc".
Use the wpa_passphrase command to generate the required network configuration by passing your essid and your pre-shared WPA key as parameters to the command, like in Figure 3.
Figure 3: Using wpa_passphrase to generate wpa_supplicant basic configuration
Copy the output (the part starting with "network=" into the file that you created before and save it.
Now we will set-up our network adapter to conntect to the wireless router. It is a good idea to create a little shell-script for this purpose. It calls wpa_supplicant and initializes the network adapter with the correct parameters:
#!/bin/bash
# a good habbit of mine
WLAN_ID=wlan1
MY_IP=192.168.0.10
ROUTER_IP=192.168.0.1
# run wpa_supplicant using "wext"
sudo wpa_supplicant -i $WLAN_ID -D wext -c /etc/wpa_supplicant.conf -B
# set the network ID to "netgear"
sudo iwconfig $WLAN_ID essid netgear
# set the connection type to "infrastructure"
sudo iwconfig $WLAN_ID mode managed
# set the IP address
sudo ifconfig $WLAN_ID up $MY_IP
# set the default route to the wireless router
sudo route add default gw $ROUTER_IP netmask 0.0.0.0 dev wlan0
Note: We have to use the Linux wireless driver called "wext" to communicate with the router, because ndiswrapper doesn't work for the Netgear MA111v2 network adapter - trust me on this. If wext fails for your adapter, you are free to try ndiswrapper instead.
If everything goes fine your network adapter should associate with the router and you should have internet access (of course the router has to be configured correctly). Check your wireless status by entering the "iwconfig" command. The output should resemble Figure 4.
Figure 4: Output of the iwconfig command showing wireless connectivity
Because we would like to have internet access the next time we boot our system, enter the following things into a terminal (the script is named "wlaninit" in the example below):
sudo cp wlaninit /etc/init.d
sudo chmod 755 /etc/init.d/wlaninit
sudo ln -s /etc/init.d/wlaninit /etc/rc2.d/wlaninit/S99wlaninit
That should do. Now reboot again and check if this configuration makes you happy. You could remove the "sudo" in front of the commands in the "wlaninit" script as they are not necessary anymore. However I would keep the original version, because sometimes the association may fail during boot-up and you have to execute the script manually.
Note: With network adapters installed through ndiswrapper it happens regularly that wpa_supplicant doesn't detect access-points and thus no wireless connection is esablished to the desired router. In such a case: unplug and replug the USB network adapter and start wpa_supplicant again. Also make sure that the interface is configured correctly by executing "ifconfig" and "iwconfig" in a terminal.
Note: With network adapters installed through ndiswrapper sometimes the wireless connection gets interrupted. You can check this with "iwconfig" by looking at the "Access Point" entry and confirming that it says "Not-Associated". In such a case kill wpa_supplicant and start it again. If that does't work: replug your USB network adapter.
Instead of configuring the network interface through a script (like "wlaninit") you can enter the configuration into the "/etc/network/interfaces" file. Check out "man interfaces" or any online manual on how to do this!
Summary: Wireless access (particularly WPA secure one) under Xubuntu can be a difficult task to accomplish if your card is not automatically supported by the system. Such network adapters have problems using WPA and sometimes won't associate at all. I therefore strongly encourage you to use a network adapter from the list of supported wireless devices on the official Linux wireless wiki (see the related section at the top)!

Official Linux wireless wiki
WPA Supplicant website