Sever Your Tether

Many laptops can now run Linux well, making it convenient to port the Penguin everywhere you go. However, wireless networks can sometimes be doggedly frustrating to use with Linux. Fortunately, some wireless cards come complete with Linux drivers, while many Windows-compatible cards and drivers can run unchanged with software called ndiswrapper. Here’s a hands-on guide sure to cure your wireless blues.
If you’re in the market for a new Linux computer, you might want to consider a laptop. Many modern 32- and 64-bit laptops rival the performance of traditional desktops, and some can be configured to offer comparable sound, graphics, and storage. Better yet, laptops are eminently portable — just try to put a tower in your briefcase or carry-on luggage.
Unlike a few years ago, many vendors — including Linux Certified (http://www.linuxcertified.com/) and Emperor Linux (http://www.emperorlinux.com/) — offer affordable laptop systems tailored specifically to run Linux. Optionally, a wide variety of consumer and business laptops can also be used to port the penguin around town. The web site “Linux on Laptops”, http://www.linux-laptop.net/, maintains a long list of capable laptop hardware.
Of course, once you have a laptop, you won’t want to be tethered to a wired Internet connection, a desk, or even an office. Luckily, given the right wireless card or a little bit of software and some patience, you and your Linux laptop will be as free as a certain chilly bird.
For Linux use, there are two kinds of wireless devices: those that have a Linux driver and those that don’t.
If you’re lucky, the wireless card you own is compatible with Linux (an extensive list of Linux-compatible devices can be found online at http://linux-wireless.org/Drivers/). Simply follow the instructions included with the driver and enjoy computing in the great outdoors.
Otherwise, you may be able to use a Windows- compatible wireless card by installing a special Linux kernel module called ndiswrapper (http://ndiswrapper.sourceforge.net/). ndiswrapper loads off-the-shelf Windows Network Driver Interface Specification (NDIS) drivers and acts as a translator between the NDIS driver and the Linux kernel. Because so many cards are compliant with NDIS, ndiswrapper can host most (but not all) Windows wireless devices. The ndiswrapper Wiki (http://ndiswrapper.sourceforge.net/mediawiki/index.php/Main_Page) recommends card and driver combinations that function particularly well with Linux.

Have Penguin, Will Travel

Let’s see what it takes to get wireless working on Linux. For this article, the test platform is an Acer Aspire 5020 laptop with a built-in PCI wireless card. Other wireless cards use USB or PCMCIA, yet configuring those types of cards is substantially similar.
There are two steps to installing a wireless card in Linux. In order, you must install software to configure the card and connect to a wireless network, and you must install the card’s driver (perhaps using ndiswrapper).
Two popular wireless configuration packages are Wireless Tools for Linux (available from http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html) and the Linux WPA Supplicant (LWPAS, available http://hostap.epitest.fi/wpa_supplicant/). Of the two, Wireless Tools supports the larger number of wireless adapters, is simpler to set up, and is often included in stock Linux distributions. You can also find a variety of graphical configuration and management tools based on Wireless Tools (see http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html# links). However, Wireless Tools doesn’t support WPA access points. If WPA access is required, choose LWPAS and read the WPA Supplicant README available at http://hostap.epitest.fi/cgi-bin/viewcvs.cgi/* checkout* /hostap/wpa_supplicant/README?rev=HEAD& content-type=text/plain. Otherwise, stick with Wireless Tools.
Before you install any wireless packages, ensure that the CONFIG_NET_RADIO extension is enabled in your kernel. Without it, you won’t be able to configure your wireless device. Most vendor kernels enable this option by default. If you have your own custom-built kernel, enable this option in the kernel coniguration menu, found in “Device Drivers& gt; Network Device Support& gt; Wireless LAN (non-hamradio) & gt; Wireless LAN drivers (non-hamradio) & amp; Wireless Extensions.”
Once you’ve booted a capable kernel, you can install the Wireless Tools. The package is offered as an RPM, or if you have a Debian system, you can install it quickly with apt-get install wireless-tools. Alternatively the source for Wireless Tools can be downloaded from http://pcmcia-cs.sourceforge.net/ftp/contrib/wireless_tools.27.tar.gz. Compilation and installation is as easy as:
$ tar xzf wireless_tools.27.tar.gz
$ cd wireless_tools.27
$ make
$ sudo make install
sudo make install adds the utilities iwconfig, iwlist, iwpriv, iwspy, iwgetid, iwrename, and iwevent to your system. Let’s return to these utilities after installing ndiswrapper and your driver.

Using ndiswrapper

Unless you found a Linux driver written for your wireless networking card, it’s worthwhile to try your card with ndiswrapper.
Installing ndiswrapper is a little involved, because part of the software is closely tied to the kernel. The ndiswrapper wiki recommends kernel 2.6.6 or newer, or kernel 2.4.26. Use uname –r to find the version number of your kernel. Building ndiswrapper from source is recommended, but a number of web sites offer pre-built packages for a number of kernel versions.
To build ndiswrapper from source, download its tarball from http://prdownloads.sourceforge.net/ndiswrapper/ndiswrapper-1.8.tar.gz?download. You also need a copy of the Linux source that matches the kernel installed on your system. Given those two pieces, you can build ndiswrapper in just a few commands:
$ tar xzvf ndiswrapper-1.8.tar.gz
$ cd ndiswrapper-1.8/
$ make distclean
$ make
$ sudo make install
make install copies the ndiswrapper module to /lib/modules/ linux-version /misc/ndiswrapper.ko and places the ndiswrapper utilities, ndiswrapper and loadndisdriver, in /usr/sbin/.
The next step provides a suitable Windows driver to ndiswrapper.
To ensure you provide a workable correct driver, start by examining your card’s chip set. Use the lspci command:
# lspci

0000:06:05.0 Network controller: Broadcom Corporation BCM4318 [AirForce One 54g] 802.11g Wireless LAN Controller (rev 02)
On the test system, the wireless card uses a Broadcom BCM4318 chip set. For any given chip set, drivers are normally available from the laptop or card vendor’s web site. (In this case. the driver is available from Acer’s website in Taiwan.) Ideally, you should use the Windows XP driver for your card, although drivers for other version of Windows are known to work fine. And if you’re running a 64-bit kernel, you need to have the 64 bit Windows drivers also — you can’t mix and match 32- and 64-bit software at this level.
Assuming that you have the correct driver, you can install it with the ndiswrapper utility.
# ndiswrapper –i bcmwl5.inf
Installing bcmwl5

(Change bcmwl5.inf to the name of the Windows INF file included with your driver.) Next, run ndiswrapper –l to verify that the driver has been installed properly:
# ndiswrapper –l
Installed ndis drivers:
bcmwl5 driver present, hardware present
Now, add an alias wlan0 for the ndiswrapper module to /etc/modprobe.conf:
# ndiswrapper –m 
Update your modules dependencies file:
# depmod –a
And now you are ready to load the wireless driver:
# modprobe ndiswrapper
Check /var/log/messages or run dmesg to check if the driver loaded successfully:
~ # dmesg

ndiswrapper version 1.8 loaded (preempt=no,smp=no)
ndiswrapper: driver bcmwl5 () loaded
wlan0: ndiswrapper ethernet device 00:0e:9b:c4:xx:xx using driver bcmwl5, 14E4:4318.5.conf
The last line above indicates that the card works with the loaded driver.You can now use the Wireless Tools you installed previously to connect to a wireless network.

Connecting to a Network

Whether your driver is native or runs via ndiswrapper, the steps to configure your wireless card from here on are the same: use iwconfig to specify the wireless network you’d like to connect to, and use iwlist to scan for wireless networks.
To begin, run iwconfig to acknowledge your wireless card. Its output likely resembles Figure One. As shown, the wireless card is recognized but isn’t yet configured.
FIGURE ONE: List the available wireless devices with iwconfig
# iwconfig
lo no wireless extensions.

eth0 no wireless extensions.

sit0 no wireless extensions.

wlan0 IEEE 802.11g ESSID: auto Nickname:
Mode:Managed Frequency:2.462 GHz Access Point: 00:00:00:00:00:00
Bit Rate=54 Mb/s Tx-Power:24 dBm
RTS thr:off Fragment thr:off
Encryption key:off Security mode:none
Power Management:off
Link Quality:100/100 Signal level:-43 dBm Noise level:-256 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:4 Invalid misc:66 Missed beacon:0
Next, scan for wireless networks with iwlist. Simply pass iwlist the name of the wireless card you wish to use, typically wlan0:
~ # iwlist wlan0 scan
wlan0 Scan completed :
Cell 01 - Address: 00:14:6C:22:97:04
Protocol:IEEE 802.11g

Bit Rate:36 Mb/s
Bit Rate:48 Mb/s
Bit Rate:54 Mb/s

You should see the wireless network you wish to connect to listed. Here, the network is called Home.
To connect to a wireless network, use iwconfig with the proper parameters. Once you have the correct settings entered, you can save the iwconfig configuration to a file to load at boot time.
Continuing the example, the access point to connect to is called Home, it uses channel 3, and access is protected with an open WEP encryption key of 3c088000210810324100568800, where the key corresponds to key one of the network keys; and uses wireless channel 3. iwconfig has many options:
# iwconfig –h
Usage: iwconfig interface [essid {NN|on|off}]
[nwid {NN|on|off}]
[mode {managed|ad-hoc|...}
[freq N.NNNN[k|M|G]]
[channel N]
[ap {N|off|auto}]
[sens N]
[nick N]
[rate {N|auto|fixed}]
[rts {N|auto|fixed|off}]
[frag {N|auto|fixed|off}]
[enc {NNNN-NNNN|off}]
[power {period N|timeout N}]
[retry {limit N|lifetime N}]
[txpower N {mW|dBm}]
To connect to Home, type:
# iwconfig wlan0 essid Home \
mode managed \
enc 3c088000210810324100568800 \
open channel 3
You can also view your settings with iwconfig. Figure Two is exemplary.
FIGURE TWO: View the settings associated with your wireless device with iwconfig
# iwconfig wlan0
wlan0 IEEE 802.11g ESSID:"Home" Nickname:"Home"
Mode:Managed Frequency:2.462 GHz Access Point: 00:C0:49:D3:E0:60
Bit Rate=54 Mb/s Tx-Power:24 dBm
RTS thr:off Fragment thr:off
Encryption key:3c08-8000-2108-1032-4100-5688-00 Security mode:open
Power Management:off
Link Quality:100/100 Signal level:-38 dBm Noise level:-256 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:13 Invalid misc:1859 Missed beacon:0
You can now bring the wlan0 interface up using ifconfig, and can assign an IP address to the interface. The command dhcpcd is helpful to obtain an address via the Dynamic Host Control Protocol (DHCP).
# ifconfig wlan0 up
# dhcpcd wlan0
(Depending on which distribution you use, dhcpcd may be called dhclient.)
The interface should now be configured and ready to use on the network, as shown in Figure Three.
FIGURE THREE: ifconfig and ping demonstrate a working wireless connection
# ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr 00:0E:9B:C4:7D:51
inet addr: Bcast: Mask:
inet6 addr: fe80::20e:9bff:fec4:7d51/64 Scope:Link
RX packets:1821 errors:0 dropped:0 overruns:0 frame:0
TX packets:2032 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1165184 (1.1 Mb) TX bytes:433421 (423.2 Kb)
Interrupt:169 Memory:c0204000-c0206000

# ping www.linux-mag.com
PING www.linux-mag.com ( 56(84) bytes of data.
64 bytes from db.linux-mag.com ( icmp_seq=1 ttl=53 time=104 ms

Starting Wireless at Boot

Now that you’ve successfully configured your wireless card, you probably want to enable the connection each time you boot Linux. The steps shown here work for Gentoo; similar steps are necessary on other distributions.
1.Ensure that the ndiswrapper module is loaded on boot. If you’re using Gentoo Linux, add ndiswrapper to the modules autoload file:
# echo "ndiswrapper" >> /etc/modules.autoload.d/kernel-2.6
2.Use ifconfig to bring your card” up” when you enter an appropriate runlevel. Assign the interface a static IP address or use DHCP to acquire one. Typically, you can just copy the configuration file of an existing interface, renaming it to match the name of your wireless interface.
# cp /etc/init.d/net.eth0 /etc/init.d/net.wlan0
3.Finally, you must store the wireless networking configuration. On Gentoo, the settings are kept in /etc/conf.d/net:
# wireless configuration
modules=( "iwconfig" )
key_Home="[1] 3c088000210810324100568800 [1] enc open"
The first line contains the name of the utility used to configure wireless, iwconfig. If, for example, you wished to use the wpa-supplicant utility, you would specify this here. If you set the essid_wlan0 entry to any, your wireless card will attempt to connect to any access point. There are lots of other options you can play with — even some that define other access points to try to connect to if the default one is unavailable. The file /etc/conf.d/wireless.example provides many examples.
You should now have a system that boots and connects to your wireless network.


Wireless in Linux is improving all the time, continually evolving to support a richer array of devices. Unfortunately, there isn’t a unified effort to develop wireless tools, and a de facto standard has yet to emerge, making wireless configuration on Linux more difficult than on other platforms. The lack of vendor-supplied drivers for Linux is also detrimental.
For now, it’s ideal to choose a wireless card that has vendor support. Short of that, Wireless Tools and ndiswrapper can break the chains that bind you to your desk, or office, or building.

Need bio here.

Comments are closed.