Building a Wireless Network with Linux

by Billy Ball

Wireless networking has been around for a while, but until recently, it was out of reach for Linux users with modest means. Fortunately, a number of manufacturers are beginning to see new venues in marketing inexpensive wireless hardware. One manufacturer, Webgear, Inc., recently introduced a Linux-compatible wireless networking kit.

In this article, I will show how to create an inexpensive wireless network and a wireless networking bridge using Webgear's Aviator 2.4 wireless networking kit, IP masquerading, software routing, a surplus laptop and Linux.

Webgear's Aviator 2.4 wireless kit consists of two Type II PCMCIA cards and two ISA PCMCIA card slots. The kit uses 2.4GHz radio technology to offer 2MBps networking using IEEE 802.11 specifications (frequency-hopping, spread-spectrum networking). The cards appear as Ethernet devices, such as eth0 or eth1, when installed and configured. The original intent of the kit is to offer the ability to create a high-speed wireless link between two desktop PCs, two laptops, or a laptop and desktop PC.

Although the kit is advertised as supporting Linux, it comes with software drivers for only Microsoft operating systems. You'll have to download the Linux device driver, a loadable kernel module named ray_cs.o, from the Web. Even though you can get a stable version through Webgear's support link at www.webgear.com/support/software_top.html, the best place to download the latest version is from the author's web site (see Resources).

Thanks to the generosity of the author, Corey Thomas, you can use the Aviator 2.4 (or more expensive Aviator Pro or Raytheon Raylink series) wireless system with Linux. I downloaded the latest driver, ray_cs version 1.68, onto one of my laptops, then followed his directions on building and installing the driver:

cp ray_cs-1.68.tgz /usr/src/linux/pcmcia-cs-3.1.5
tar xvzf ray_cs-1.68.tgz
make config
make all
make install

These steps should then be repeated on another computer. I initially used two laptops to test the connectivity of the cards. This is essential to ensure the cards and software are working correctly. I had great success with a later version of David Hinds' Card Services, pcmcia-cs 3.1.5, along with the next version, pcmcia-cs 3.1.6.

Peer-to-Peer Wireless Networking

As sold, the kit allows for connection between two wireless points: point A-->point B.

Before enabling the cards, you must first edit /etc/pcmcia/config.opts and insert the line

source ./ray_cs.opts

Upon starting, Card Services will then read in the ray_cs.opts configuration file for the wireless cards (ray_cs.opts is copied into the /etc/pcmcia directory as part of make install). This file contains several important settings, in the form of setup strings, used to configure the Aviator 2.4 card after insertion. The settings line (there are several, as the driver supports at least three different wireless cards) I used was:

module "ray_cs" opts "pc_debug=2 essid=LINUX\
 hop_dwell=128 beacon_period=256 translate=1"
Make sure to use the same settings for each end of the wireless connection. The pc_debug=2 option is a handy way to get more information from /var/log/messages upon insertion or removal of the card. The essid=LINUX option designates a network name of LINUX for the wireless cards (according to Webgear, 61 cards may be on the same network). After installing and configuring the software, I used Red Hat's netcfg tool to create an eth0 interface on each laptop. You can also create your own by editing the /etc/sysconfig/network-scripts/ifcfg-eth0 file:
DEVICE=eth0
IPADDR=192.168.2.37
NETMASK=255.255.255.0
NETWORK=192.168.2.0
BROADCAST=192.168.2.255
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
The cards must be started sequentially. I went to the first laptop, ensured Card Services was running (you can do an /etc/rc.d/init.d/pcmcia start), then inserted one of the Aviator cards. Upon hearing two beeps, I looked at the output of /var/log/messages (not all the output is shown here):
$Id: ray_cs.c,v 1.68 1999/11/21 10:43:35 corey Exp
$-Corey Thomas
corey@world.std.com
ray_cs Detected:
WebGear PC Card WLAN Adapter Version 4.88 Jan 1999
eth0: RayLink, irq 4, hw_addr 00:00:8F:48:E8:DB
ray_cs interrupt network "LINUX" started
The important thing to look for is the “started” string. I then enabled the interface using netcfg, as according to Thomas, you cannot use the ifconfig command to set the IP address using the ray_cs driver. I then went to the other laptop, inserted the other Aviator card, listened for the two beeps, and looked at /var/log/messages:
$Id: ray_cs.c,v 1.68 1999/11/21 10:43:35 corey Exp $-Corey Thomas
corey@world.std.com
ray_cs Detected:
WebGear PC Card WLAN Adapter Version 4.88 Jan 1999
eth0: RayLink, irq 10, hw_addr 00:00:8F:48:E8:45
ray_cs interrupt network "LINUX" joined
Again, the important string to look for is “joined”. This means the cards are communicating. I then enabled the eth0 interface, and voil<\#224>--I could use ping, telnet, ftp and talk between the two laptops wirelessly. FTP file transfers were about 180K per second, and that speed is reasonable enough for remote X11 client launching. This shows that Linux can be used to support wireless networking in a variety of situations where cabled installations are impractical or unnecessary.
Wireless Masquerading from a Server

While being able to network two laptops wirelessly is a lot of fun and can be quite handy, I was still not satisfied. I have a local area network (LAN) in the house, spanning several computers hubbed together in the basement and up two levels to an upstairs office with another hub of three computers. Being a Linux user, I want more from my hardware and wanted to get much more functionality out of my wireless network. I wanted to be able to roam the house or sit by the pool with a wireless laptop, and also network with all computers on the LAN while browsing the Web, doing e-mail and so on. The cards are advertised as being able to communicate at least 500 feet through walls and 1000 feet within “line of sight”.

Unfortunately, according to Webgear, the Aviator 2.4 cards are meant to be used only for peer-to-peer networking. If you purchase the Aviator Pro line of cards, you can then buy a piece of hardware called a wireless “access point” that hooks into your LAN via RJ45 to provide a bridge into your network or from another network. The access point costs several hundred dollars, even with diligent Internet shopping. A wireless access point is not offered for the Aviator 2.4 series.

This is where being a member of a Linux users group comes in handy. Thanks to friends in the Northern Virginia Linux Users Group, NOVALUG, I was able to create my wireless network. Following tips from messages on NOVALUG's mailing list, I installed one of the Aviator ISA PCMCIA slot adapters in my server in the basement. The server's first interface, eth0, has an assigned IP address of 192.168.2.XX. I installed the Aviator card as eth1 with an IP address of 192.168.1.1. After the wireless card was “started”, I then used the route command to route wireless (eth1) traffic through eth0:

/sbin/route add 192.168.1.1 gw 191.168.2.

To complete the services, I then crafted a simple IP masquerading script (based on information courtesy of Greg Pryzby, NOVALUG's founder):

#!/bin/sh
case "$1" in start)
      /sbin/modprobe ip_masq_ftp
/sbin/ipchains -A forward -s 192.168.2.0/24 -j MASQ
/sbin/ipchains -A forward -s 192.168.1.0/24 -j MASQ
      echo "NAT Started" ;; stop)
/sbin/ipchains -F
      echo "NAT Stopped" ;; *)
      echo "Usage: ipmasq {start|stop}" ;;
esac
After enabling my PPP connection, wireless card, masquerading and routing on the server, then connecting to the rest of the LAN and using the Internet from my wireless laptop (with an assigned IP address of 192.168.1.2) was quite simple. Again, using the route command, but this time on the wireless laptop:
/sbin/route add default gw 192.168.1.1
This configuration allowed me to communicate with all the other computers on the LAN (such as LaptopA and ComputerB), along with access to the Internet.

Figure 1. Network Configuration

Wireless Masquerading from a Laptop

Then I ran into trouble. When I was down in the basement near the server, connection tests ran okay with the wireless laptop. However, when I ranged too far from the server, for some reason the cards would lose communication, or I could not “join” the “started” server connection. If you read more about wireless networking's coverage and reliability, you'll learn that the quality of a connection can be influenced by many factors. I later found out the equipment in the basement was located too close to an earthen wall, and for some reason, the signal was being blocked. I had to move the connection, but I still wanted full access to the LAN and the Internet.

I then removed the Aviator card from the server and reinstalled the card on an ancient spare laptop (LaptopA) upstairs with two Type II PCMCIA slots. Like the server, one laptop slot provided an eth0 interface to the LAN (with an IP of 192.168.2.32), while the other was configured as eth1 with the wireless card (and an IP of 192.168.1.1). IP masquerading on the server was forwarding packets from the PPP connection to the laptop, but in order to provide service to the wireless laptop, I had to use IP masquerading on LaptopA again:

/sbin/ipchains -A forward -s \
192.168.1.0/24 -j MASQ

Now everything worked fine! I could communicate with the rest of the LAN (such as from the Wireless to Computer B or the Server).

A simple route command on the server, using the wireless laptop's IP address along with the “hardwired” eth0's IP address (from LaptopA) also allowed the rest of the LAN to ping the wireless computer:

/sbin/route add 192.168.1.2 \
gw 192.168.2.XX

Believe me when I say it was somewhat of a learning experience—I never envisioned having to forward information from two computers.

Bridging: An Alternative

I found out you also can easily build a wireless bridge, and thus not have to use routing to allow a wireless connection to connect to the rest of a LAN. Using a spare laptop, I first recompiled Linux to enable bridging. I then installed an eth0 interface with an assigned IP address to connect to the LAN. Next, I installed the Aviator card as eth1 without an assigned interface, then brought up both interfaces in promiscuous mode with

/sbin/ifconfig eth0 promisc up
/sbin/ifconfig eth1 promisc up

Next, I downloaded Alan Cox's brcfg utility, and enabled bridging with

 ./brcfg -ena
After starting a wireless connection, I could then access any computer on the LAN from the wireless laptop.
Conclusion

Wireless networking may not be the best solution if you need high-speed communication on or between your LANs, but the combination of Linux and a legacy laptop shows that you can build a useful and flexible wireless network at low cost. This is just one of the reasons I use Linux (besides being able to surf the Web while drinking a pool-side Margarita—with salt, on the rocks, thank you).

Resources

Acknowledgements

Bill Ball is a member of the Northern Virginia Linux Users Group (NOVALUG), and the author of nearly a dozen books about Linux. He may be contacted through http://www.tux.org/~bball/.

Load Disqus comments

Firstwave Cloud