Hack 63. Build Your Own Access Point with Linux

Table of contents:

Run your own access point with off-the-shelf radio cards and open source drivers.

Commercial access points have multiple functions. Not only do they have 802.11a/b/g radios, but they also function as the master of any client radio that connects to the AP in Infrastructure mode. Access points broadcast beacon frames, which advertise the ESSID of the access point. Once a client associates, the access point manages all radio communications, following sets of algorithms to control radio traffic between multiple clients.

The challenge here is to accomplish the same task without the custom chipsets and firmware in commercial access points. You want to build your own access point using a laptop (or other PC hardware), a radio card, and some software.

5.2.1. Hardware Choices

What you choose to build your access point really depends on how and where you want to use it:



If you have a notebook, isn't that a perfect platform to always have with you as an access point? You have several options: connect your laptop to an Ethernet drop if one is available, use WDS [Hack #69] to redistribute an existing wireless signal, or even uplink via a data-capable mobile phone as your backhaul [Hack #4].



There are a number of manufacturers of small form factor PC hardware that either are designed specifically with wireless use in mind or have all the features that you need to build an access point. "Do-It-Yourself Access Point Hardware" [Hack #53] covers some of these boards.


Existing hardware

Just about any PC hardware you can think of will make a capable access point. Intel architecture is not even a limiting factor here. One of the wireless routing nodes built for the West Sonoma County Internet Cooperative (http://www.wscicc.org) in Sonoma County, California, was a beige Macintosh G3/266 desktop machine. It ran Yellow Dog Linux and had two PCI-PCMCIA converters housing two Agere Orinoco Silver 802.11b radio cards. An odd choice, you might think, but it functioned as a wireless router for over a year.

5.2.2. Radio Cards and Antennas

Three radio chipsets and associated drivers are capable of running in Master mode under Linux, which allows the driver to assume functions in software that a commercial access point performs with custom hardware and firmware:

  • Prism 2/2.5/3 802.11b radio cards with the HostAP driver
  • Atheros 802.11a/b/g radio cards with the Madwifi driver
  • Prism54 802.11b/g radio cards with the Prism54 driver

It can be maddeningly difficult to determine just what chipset your particular radio card uses; this book dedicates an entire hack to this subject. If you don't yet have a wireless card and are planning an access point project, read through "Find Radio Manufacturers by MAC" [Hack #39] first, do some research, and make sure you're buying the right card.

External antennas are covered in a whole series of hacks in this book, from the infamous Pringles can [Hack #85] to determining the gain of your home-built antenna [Hack #92]. If you're planning deployment of either a single AP for outdoor point-to-point use or multiple APs to cover a large building, you'll need external antennas specific to your project. See Appendix B for a complete tutorial on external antennas, cables, and connectors that you'll need to be familiar with.

Prism54 Cards

Prism54 cards are a third option for your access point. However, there is an issue with the cards currently being sold that makes it difficult to recommend them. The Prism54 chipset is available in a SoftMAC format, which is analogous to the Atheros cards; much or all of the radio is controlled entirely from software.

This has necessitated a complete rewrite of the Prism54 Linux driver. At the time of this writing, the driver does not support SoftMAC cards, and these are the only cards available on the market.

You can consult http://www.prism54.org/supported_cards.php for updates to the list of supported cards, and more information on the SoftMAC issue.


5.2.3. Software Requirements

This hack uses Linux as its base operating system. Again, depending on your host hardware, you have a number of choices. Small board PCs with limited amounts of memory will need custom distributions such as Pebble [Hack #70] or, if you're familiar with BSD, m0n0wall [Hack #71]. If you're using a notebook PC, just about any distribution you want would be appropriate, because they all support the wireless card drivers described later in this section. The examples in this hack use Ubuntu and Fedora Core distributions.

The following section covers the installation of drivers for each type of wireless card that supports Master mode. All example driver installs and configurations assume that you have the following:

  • Linux kernel 2.4.20+ or 2.6.x with CONFIG_NET_RADIO enabled
  • Wireless Tools v15 or later
  • Development environment including the GCC compiler

5.2.4. HostAP

The author and maintainer of the HostAP driver is Jouni Malinen, and his web site for HostAP is located at http://hostap.epitest.fi. In addition to the HostAP driver, he is also the author of the hostapd daemon and wpa_ supplicant [Hack #42]. If you run into problems with any of his projects, mailing lists hosted at the site can be a great deal of help. There is also anonymous CVS access for anyone who wants to run bleeding-edge code.

There are a couple of ways to get the source code for HostAP. Both options require you to compile from source. Ubuntu package install.

Ubuntu users can use apt-get to install the hostap-source package from the universe repository. In order to do this, you'll need to configure apt. Edit /etc/apt/sources.list and uncomment the following lines:

	deb http://us.archive.ubuntu.com/ubuntu hoary universe
	deb-src http://us.archive.ubuntu.com/ubuntu hoary universe
	deb http://security.ubuntu.com/ubuntu hoary-security universe
	deb-src http://security.ubuntu.com/ubuntu hoary-security universe

The universe repository contains packages that are not developed or supported by the Ubuntu release crew. This is where you'll find the hostap-source package.

The default kernel image installed by Ubuntu on Intel platforms appears to be the i386 architecture build. This kernel does not come with CONFIG_NET_RADIO enabled. However, all of the other available Ubuntu kernels do have this option enabled by default. This example uses the 2.6.10-5-686 kernel image.

You'll also need to get the Linux-headers package that matches the kernel version you are currently running. A quick way to determine your kernel version is to execute the uname command:

	$uname a
	Linux hostname 2.6.10-5-686 #1 Tue Apr 5 12:12:40 UTC 2005 i686 GNU/Linux

To update your apt index, issue the following command:

	sudo apt-get update

Once apt has finished updating the indexes, go ahead and install the packages:

	sudo apt-get install hostap-source hostap-utils linux-headers-2.6.10-5-686

Lastly, you'll need to create some symbolic links so that compilation of kernel modules doesn't fail to find the necessary headers:

	cd /lib/modules/2.6.10-5-686
	ln -s /usr/src/linux-headers-2.6.10-5-686 source
	ln -s /usr/src/linux-headers-2.6.10-5-686 build
	ln -s /usr/src/linux-headers-2.6.10-5-686 /usr/src/linux

The hostap-source package will be placed in /usr/src/hostap-source.tar.bz2. Unpack the file, change to the newly created directory, and build the modules:

	tar xjvf hostap-source.tar.bz2
	cd modules/hostap-source
	sudo make
	sudo make install

Once the modules are built and installed, you can load the modules:

	sudo depmod ae
	sudo modprobe hostap

Insert your Prism 2/2.5/3 PC Card, or shut the system down and install your Prism 2.5/3 PCI card, and skip ahead to the "Configuring Your AP" section. Compiling from source.

Fedora Core users should download the source code package directly from http://hostap.epitest.fi. The compilation test for this hack, on a stock Fedora Core 3 system, was painless:

	tar xzvf hostap-driver-0.3.7.tar.gz
	cd hostap-driver-0.3.7
	sudo make
	sudo make install

The make install took care of running depmod, so all that was left was to execute the following command and insert the Prism 2 PC card:

	sudo modprobe hostap


5.2.5. Madwifi

Atheros radio chipsets are designed rather differently from some other Wi-Fi equipment on the market. In a nutshell, the software driver for Atheros cards has a lot more functionality than other chipsets, and as such is much more powerful.

The development of a driver for the Atheros chipset was difficult from an open source standpoint. There was originally a BSD driver developed for the Atheros chipset with the help of Atheros engineers. However, the driver did not enforce valid modes, which would permit users to violate FCC regulations by allowing the setting of invalid radio modes on client radio hardware. In other countries, regulations would allow governmental enforcement to be taken out against the hardware manufacturer for allowing invalid radio modes.

The solution to this problem was for Atheros to allow the development of a Hardware Abstraction Layer (HAL) by Sam Lefler. The HAL is in binary form and sits between the driver and the hardware to enforce valid FCC operating modes. This is viewed by some in the open source community as a black sheep project, one that pollutes the licensing of the Linux kernel by introducing code for which there is no available source.

That argument aside, the Multiband Atheros Driver for WiFi (Madwifi) was for quite some time the only available driver for Linux or BSD. It is still the only driver for Linux that allows the use of Master mode with Atheros radio cards. BSD users have the option of using the ath(4) driver, which has been developed by some of the same people responsible for Madwifi.

Until fairly recently, no package installs were available for Madwifi. That has changed, however, and more than one recent distribution now includes the Madwifi driver by default. The following sections show how to add the driver if your Ubuntu install did not include the right package, as well as how to compile from source. Ubuntu package install.

Installations of Ubuntu 4 and the recent 5.04 release both include packages titled linux-restricted-modules, which are described as "non-free Linux modules" for various architectures. If an Atheros-based Wi-Fi card was present in your machine during Ubuntu installation, this package should have been installed. It contains the Madwifi driver, along with other drivers that are not fully compliant with the Gnu Public License (GPL).

If you don't have this package, you can get it from the Ubuntu install CD or by modifying your /etc/apt/sources.list to add the universe repository as described previously in the "HostAP" section. Once you have updated apt, locate the correct package for your architecture:

	apt-cache search linux-restricted-modules

This will return a list of all possible architectures for which the package is available. In our case, we are using the 686 kernel, so we need to install the appropriate package:

	apt-get install linux-restricted-modules-2.6.10-5-686

After installation you can reboot, or execute these three commands as root to load the necessary modules:

	modprobe wlan
	modprobe ath_hal
	modprobe ath_pci Compiling from source.

Compilation of the driver is not complicated, but since the driver is a work in progress the developers have not yet put out a production release. You'll have to get the source code via a Subversion checkout, which is a simple one-line exercise:

	svn checkout http://svn.madwifi.org/trunk madwifi-ng

This checks out the most current preview edition of the code, and drops it all in a folder titled madwifi-ng in the root of where you executed the svn command. You should be able to change to the madwifi-ng folder and just type make. For the most up-to-date information on Madwifi code releases, check with http://madwifi.org/wiki/UserDocs/GettingMadwifi.

However, we ran into a snag here with our Fedora Core 3 installation. The make failed with an error, because it could not find the uudecode command. The binary HAL file is included in the source code as a uuencoded file. For some reason, our Fedora Core 3 default install didn't include the sharutils package containing uudecode, so we used yum to install it and then compile:

	yum install sharutils
	make install

Now, you can reboot or execute the modprobe commands listed earlier to activate the driver modules.

5.2.6. Configuring Your AP

Now that you've got the radio card and the driver, it's time to have them start acting like an access point. The manual method for this is simple, using the Linux Wireless Tools:

	iwconfig ath0 essid "Example" mode Master channel 6 rate Auto

This sets up your wireless card in Master mode, broadcasting the SSID of Example, on channel 6 using any wireless speed rate. This is easy to verify; just boot up any other machine you have with a wireless card and scan for available access points. Your newly configured machine should show up. You can also call iwconfig to verify your settings:

	iwconfig wlan0

	wlan0	IEEE 802.11b ESSID:"Example"
			Mode:Master Frequency:2.437GHz Access Point: 00:02:6F:01:85:74
			Bit Rate:11Mb/s Tx-Power=24 dBm Sensitivity=1/3
			Retry min limit:8 RTS thr:off Fragment thr:off
			Encryption key:off
			Power Management:off
			Link Quality:0 Signal level:0 Noise level:0
			Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
			Tx excessive retries:0 Invalid misc:0 Missed beacon:0

If you're setting up a permanent access point rather than something temporary on your laptop, you won't want to have to manually configure the radio each time the system loses power or reboots. Traditionally, the accepted method for configuring wireless card radio parameters was in the /etc/pcmcia/wireless.opts file. However, this works for PCMCIA-based radio cards only, and you have to also configure /etc/pcmcia/network.opts or another file somewhere else to assign TCP/IP parameters to the card.

Fortunately, current Linux distributions have other methods of configuring wireless cards that allow for all necessary parameters in a single file. Ubuntu and Debian users should modify the entry in the /etc/network/interfaces configuration file. Here's example with a static IP address:

	iface ath0 inet static
		wireless_mode master
		wireless_essid Example
		wireless_channel 6
		wireless_rate Auto
	auto ath0

Fedora Core and Red Hat users will need to dig another level deeper and edit the correct file in /etc/sysconfig/network-scripts. There will be an ifcfg file that corresponds to your wireless card driver. In our case, with a Prism II card, the file was ifcfg-wlan0. Again, here's an example with a static IP address:


There's one further caveat when using the PCMCIA Host AP driver: some machines (notably, the Stylistic 1000 [Hack #53]) have a problem loading the Host AP driver with some Prism II cards. The symptom is that the card is detected on insert but mysteriously fails to initialize, reporting an obscure error to the effect of "GetNextTuple: No more items." If you are having trouble with the driver, try adding this line to your /etc/pcmcia/hostap_cs.conf (replacing any existing module "hostap_cs" line):

	module "hostap_cs" opts "ignore_cis_vcc=1"

Normally, the driver attempts to verify that one entry on the card's acceptable voltage table matches the voltage reported by your PCMCIA slot. In some cases, this voltage can be incorrectly reported, causing the driver to fail to initialize. This option causes the driver to ignore the reported voltage and load anyway.

5.2.7. Hacking the Hack

This is all you need to do to bring up a simple access point on your Linux machine. There are much more elaborate tweaks available that allow you to bridge your wireless and wired networks [Hack #64], bridge two access points together [Hack #69], and bridge a firewall [Hack #65].

Bluetooth, Mobile Phones, and GPS

Network Discovery and Monitoring

Wireless Security

Hardware Hacks

Software Hacks

Do-It-Yourself Antennas

Wireless Network Design

Appendix A. Wireless Standards

Appendix B. Wireless Hardware Guide

Wireless Hacks
Wireless Hacks: Tips & Tools for Building, Extending, and Securing Your Network
ISBN: 0596101449
EAN: 2147483647
Year: 2004
Pages: 178

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net