Wherefore Art Thou, Oh Access Point? (Cooking with Linux)

This column, by Marcel Gagné, first appeared in the September 2005 issue of Linux Journal.

Oui, François. The access point by the fireplace is much better one for you to connect to. The ESSID? It's cmfireplace. You'll see it in the list if you scan for it. Quoi? Mon Dieu, François, you aren't actually editing a script, are you? While I admire your desire to get comfortable with the shell, it would be much easier for you to select the scan for the access point, select, click, and go.

Ah, I see! The Linux driver for your card doesn't support scanning. Yes, I had a similar problem with mine, but I have a solution. I'll show you in a little while but time is short and our guests will be here any moment. Quick! To the wine cellar, François. I can see our guests arriving as we speak. Head to the South wing of the cellar and bring back the 1983 Batard Montrachet. Vite!

Welcome, mes amis, to Chez Marcel, home exceptional Linux fare, fine wines, and wonderful guests, of course. Please sit and make yourselves comfortable. Your tables are ready, complete with notebooks for tonight's menu. François, is in the wine cellar -- ah, he has already returned! Excellent. Please, François, pour for our guests.

Before you arrived, my faithful waiter and I were discussing some problems we have experienced with our wireless cards. While my own notebook's wireless card worked fine on my home network, it only worked so well. The standard Linux orinoco driver that supported the card didn't allow for things like scanning. Every month, I head down to the TV studios to record a show and every month I wind up asking which wireless router I can use since I had to manually enter the information into the network configuration file (ifcfg-eth2).

Of course, the Windows driver for the wireless network card supported these features and, as sometimes happens, manufacturers aren't 100% forthcoming with information or specifications to make full Linux support easy. I truly admire the incredible talent and energy of Linux developers who provide Linux with excellent drivers while working in a vendor black hole. Nevertheless, this lack of information was the impetus for the NdisWrapper project which makes it possible to use Windows Ndis drivers via a loadable Linux kernel module.

Here's how it works. First, you'll need to get a copy of NdisWrapper from the project's Website (http://ndiswrapper.sourceforge.net). That will guarantee you the latest version. That said, if you have a recent Linux distribution, check your CDs first. You may find you already have the software. Second, you need the Windows drivers that came with your card, specifically the INF file for that card.

Here's an example from my own Presario notebook which came with a built-in LanExpress card. Under Linux, connectivity was supported by the Orinoco driver, but as I mentioned, scanning did not work. Since I never actually installed Windows on my notebook -- it was there, but I put in a Linux CD before I ever booted the unit so I never had Windows working on it -- I went to the HP Website and downloaded the driver file (in a self-extracting EXE file). I used CrossOver Office to extract the package, then navigated to the folder where the package was located. Using ndiswrapper, I installed the driver via its INF file (this must be done as the root user).

ndiswrapper -i NetWlan.INF
Installing netwlan

Looking at the output above, it doesn't look like a lot has happened. By using the "-l" flag, we can find out what drivers have been loaded and the status of those drivers.

ndiswrapper -l
Installed ndis drivers:
netwlan driver present, hardware present

The next step is to load the driver into the running kernel and that's done by loading ndiswrapper itself.

modprobe ndiswrapper

The net result of this (just a little pun, mes amis) can be seen by looking at the output of the dmesg command.

ndiswrapper version 1.2rc1 loaded (preempt=no,smp=no)
ndiswrapper: driver netwlan (LAN-Express,01/18/2002,1.07.29.20118) loaded
ACPI: PCI interrupt 0000:00:09.0[A] -> GSI 10 (level, low) -> IRQ 10
ndiswrapper: using irq 10
wlan0: ndiswrapper ethernet device 00:02:8a:a9:e6:eb using driver netwlan,
configuration file 1260:3873.5.conf
ndiswrapper (set_auth_mode:584): setting auth mode failed (C0010015)
wlan0: encryption modes supported: WEP

Excellent, I now have the Windows driver loaded into our Linux system and we are ready to go. To have all this happen magically at boot time, I added the steps (minus the dmesg) in my rc.local file.

It would appear, François, that some of guests' glasses are looking a little dry. Please offer them a top-up.

Now, you could get a list of wireless access points near you by using the iwlist command with the scan option. Assuming a wireless interface at eth2, the command would be iwlist eth2 scan. I could then use the iwconfig command to attach to the my network of choice, assign an IP address, and so on. However, it would also be nicer for the whole desktop experience to have a graphical alternative, one that could scan for networks, report on the quality of the signal, then offer a means of connecting to the service you choose. The notebook, after all, is also a desktop tool.

One of the best such tools I've found is Pawel Nawrocki's Wireless Assistant. This is a great looking little program that lets you scan for available wireless networks, then connect to them with a single click. Each identified network is identified by factors such as link quality and encryption. The application can be configured to automatically handle WEP keys, ignore various types of networks (ad-hoc or encrypted), automatically run a script upon connection, and more. Figure 1 shows the application in action.

Note : Click on small images for a larger version.

The Wireless Assistant Web site, http://wlassistant.sourceforge.net,has source code available as well as binary packages for several distributions. By the way, I'll mention right now that the SourceForge site has only code available. If you want to track discussions on the package, the KDE-Apps.org (see Resources) site is the better place to look for that information. Building the application from source is a classic extract and build five-step.

tar -xjvf wlassistant-0.3.9.tar.bz2
cd wlassistant-0.3.9
./configure --prefix=/usr
make
su -c "make install"

The actual program name is wlassistant. When the package first starts, it will automatically check for your active network device. If it doesn't, click the Detect button. If you are still having problems, it is possible that the path to the wireless tools haven't been properly set. Click the Configure button and a configuration dialog will appear. In the left-hand sidebar, categories of options are listed while the actual changes take place in the larger right-hand window. Click the Paths button to confirm the pathnames to the wireless tools commands (figure 2). You can either enter then manually or click the Detect button.

Figure 2 : Use Wireless Assistant's configuration dialog to set the pathnames to the wireless tools.

While you are in the configuration dialog, take some time to examine the other options at your disposal. When you are happy with the settings, click OK to return to the main Wireless Assistant window. If you haven't already done so, click Rescan to locate your available access points (figure 1). As you can see from the image, there are a handful of networks for me to choose from. The display also shows whether or not an access point uses WEP encryption (this is always a good idea unless you actually want to provide open access to whoever comes your way).

Click the entry of your choice and a box will appear so you can enter the root password (figure 3). You connection will be established. That's all there is to it.

Figure 3 : Before switching your network settings, you will need to provide the root password.

When I was visiting clients and tying into a variety of networks, I created a little script that copied ifcfg-ethX and network back and forth depending on the site I was visiting that day. It worked, but it wasn't the most elegant solution. In the world of wireless connections, this hasn't changed. If you are moving from access point to access point, office to office, and then back home, you're going to want some kind of help in maintaining all those different profiles. This is true whether you are dealing with wireless or one of those old-fashioned wired connections, non?

This is the idea behind Per Johansson's netGo (see figure 4). This is a great little application that lets you create network profiles of all kinds, then, then switch between then with a click. When not in use, the application docks into your system tray. The program itself is a QT application, but it works equally well with KDE or GNOME (and others).

Figure 4 : netGo makes it easy to set up and maintain a number of network profiles.

To get your copy, head to http://netgo.hjolug.org/. If you choose to build from source, this is your basic extract and build five-step so nothing too scary here. To run the application, run the command netgo. You'll be asked to provide the root password at this point so that you can make network address changes later.

At first, the main window won't contain any profiles. To start the process, click the "Add profile" button and a new window will appear (figure 5). At the top, enter the profile name (eg: HomeLAN, CoffeeShop), then choose an interface card (many notebooks will have a built in 10/100 Ethernet card in addition to the wireless card). For connections that require a static IP address, fill in the information in each of the fields for IP address, Netmask, and so on.

Figure 5 : Entering connection details for a netGo profile.

When you are done, click the OK button to save your profile. If the connection you are setting up is wireless, click on the "More options" button. There, you can enter the network mode (ad-hoc, managed, none), the ESSID, and the WEP key. Notice also the "Custom script" field. This provides a means of automatically executing a series of commands (eg: a custom firewall script) when bringing up the interface. Click the Back button to return to the main configuration screen.

Continue adding as many profiles as you need in the same manner. To activate a profile and apply your network settings, click on the profile name, then click the button labeled "Go!" to apply the changes. A status window will appear displaying the new settings (figure 6).

Figure 6 : netGo reports back on the changes that were made as the profile executes.

The only real drawback I've found to netGo is that it doesn't currently provide for taking down your second interface so this still needs to be done manually if needed. But according to the Per's Web site, this feature is in the works as I write this.

Is would appear, mes amis, that closing time has arrived, if that clock on the wall is to be believed. Nevertheless, I'm sure that François won't mind if we keep the doors open a little longer; time enough to refill your glasses one last time. We can even bring out a little of that double-butter Brie to accompany the wine. Since we are all running wireless tonight, perhaps everyone can carry their notebooks outside to the patio where we can enjoy the evening before we all head home. Please raise your glasses, mes amis, and let us all drink to one another's health.

A votre santé! Bon appétit!

Resources

NdisWrapper
http://ndiswrapper.sourceforge.net

netGo
http://netgo.hjolug.org/
http://www.kde-apps.org/content/show.php?content=21832

Wireless Assistant
http://www.kde-apps.org/content/show.php?content=21832
http://wlassistant.sourceforge.net