1. Changelog
  2. Todo
  3. Warnings/Preface
    1. Basic Expectations
    2. Basic Diagram of Component Interaction
    3. Understanding what each part does
  4. Get Code & Patch
  5. Extract Tarballs
  6. libnl
  7. crda
  8. iw
  9. hostapd
  10. compat-wireless
  11. configure hostapd
  12. Addendums/Notes/FAQ
    1. ath9k notes
    2. iwconfig wlan0 mode master fails
  1. Changelog

  2. Todo

  3. Warnings/Preface

    AP Mode is still VERY hit and miss for driver support. I maintain quite the collection of wireless devices and regularly test them all. I'm also working on growing my collection to eventually include a sample of ALL devices that have mac80211 driver support, and would like to maintain this document to include them all. That may be a pipe dream as I have a real job that dictates the amount of time I have available for testing.

    It's quite possible that you can complete this guide only installing compat-wireless and hostapd. Distros have begun shipping iw, crda, and recent libnl versions. I'm including those steps for now as I won't assume ANY of the packages needed are available.

    Basic expectations:

    1. Linux Kernel 2.6.27 or later with wireless extensions enabled
      The compat-wireless patchset is not maintained for kernels older then 2.6.27, making older kernels impractical targets.
      Your kernel MUST be compiled with mac80211 support enabled. Without this, one of the data structures won't contain values used by the wireless drivers.
    2. Comfortable using the command line
    3. Not afraid to break the system we're configuring
    4. Basic developmental tools available (gcc, autoconf, git)
    5. The account being used to do this has sudo abilities
    6. You have a good system backup, and a working restore procedure

    Basic Diagram of Component Interaction

    [Wireless Card]
    [Linux Kernel ]
      |    |
       |  /   \       
     [crda]    \     
        |       \     
    [ Wireless ] |
    [Regulatory] |
    [ Database ] |
            [ hostapd ]

    Understanding what each part does

    Wireless Card: Should be self explanitory... handles sending/receiving wireless packets

    Linux Kernel: The linux kernel contains the driver for the wireless card, the mac80211 subsystem which handles packet generation and scheduling, and the nl80211 subsystem, which handles configuring the wireless interfaces for userspace

    libnl: libnl is the transport layer used to communicate with the kernel via netlink

    udev: udev is the facility the kernel uses to pass events/calls to crda

    iw: iw is a userspace utility that we can use to test that libnl is working correctly, as well as create additional virtual wireless interfaces on the wireless card

    crda: crda is a userspace program that the kernel queries (through udev) to find what channels/frequencies are usable, and at what powers. This moves the information out of static tables maintained in kernel to userspace, which allows them to be updated without reloading drivers/rebooting

    Wireless Regulatory Database: database of allowable frequencies and transmit power levels used by crda

    hostapd: This is the daemon that handles generation of beacons and other wireless packets, as wel as wpa-psk, wpa2, etc encryptions.

    Successes/Failures/Questions/Concerns to: wireless@erley.org

  4. Get Code

    Known working versions:

    Tested drivers and the wireless-testing git commit tested:
    Yes, I've only run-time tested with the git module. Sorry I haven't tested the tarball
    # you'll want to change this if you're doing this somewhere other than /usr/src
    cd /usr/src
    # Get compat-wireless
    wget http://wireless.kernel.org/download/compat-wireless-2.6/compat-wireless-2009-02-21.tar.bz2
    # Get wireless regdb
    wget http://wireless.kernel.org/download/wireless-regdb/wireless-regdb-2009.01.30.tar.bz2
    # Get crda
    wget http://wireless.kernel.org/download/crda/crda-1.0.1.tar.bz2
    # Get libnl (optional)
    wget http://people.suug.ch/~tgr/libnl/files/libnl-1.1.tar.gz
    # Get Hostapd, wpa-supplicant, etc...
    wget http://hostap.epitest.fi/releases/hostapd-0.6.8.tar.gz
    # Get iw 
    wget http://wireless.kernel.org/download/iw/iw-0.9.9.tar.bz2
  5. Extract Tarballs

    # Compat Wireless
    tar xjvf compat-wireless-2009-02-21.tar.bz2
    # wireless regdb
    tar xjvf wireless-regdb-2009.01.30.tar.bz2 
    # crda 
    tar xjvf crda-1.0.1.tar.bz2 
    # libnl
    tar xzvf libnl-1.1.tar.gz 
    # hostapd
    tar xzvf hostapd-0.6.8.tar.gz 
    # iw
    tar xjvf iw-0.9.9.tar.bz2
  6. Build libnl & install it

    Note, as of the latest update to this document, I was unable to DL the latest libnl

    # You only need to do this if your distro doesn't ship a relatively recent version
    # of libnl.  Most distros are shipping libnl-1.1 or later, which will work for
    # what we need.
    cd libnl-1.1
    # This is going to install libnl into /usr.
    # you may need to point this elsewhere for your system.
    ./configure --prefix=/usr
    make && sudo make install
    cd ..
  7. Build crda & install it (and install the wireless regdb)

    cd wireless-regdb-2009.01.30
    # First we need to create the location for the wireless regulatory
    # database
    mkdir -p /usr/lib/crda
    # Now we copy the regulatory db over.  Note, no need to 'make' here as
    # the wireless regdb shipped by git is already signed and setup as needed
    cp regulatory.bin /usr/lib/crda/
    cd ..
    # Now we build crda
    cd crda-1.0.1
    # I HIGHLY recommend installing this as it configures udev for using crda
    # automatically.
    make && sudo make install
    cd ..
  8. Build iw & install it

    cd iw-0.9.9
    # You can leave out the 'sudo make install' if you don't want
    # to install iw or overwrite your system iw.
    make && sudo make install
    cd ..
  9. Build hostapd & install it

    cd hostapd-0.6.8
    # Copy the default config to .config for use during this build
    cp defconfig .config
    # Edit .config
    vi .config 
    #  you need to uncomment these lines, at a minimum, and make sure
    #  CONFIG_LIBNL_LOC points to wherever you installed libnl to in
    #  step 3.
    #  CONFIG_DRIVER_NL80211=y
    #  LIBNL=/usr
    #  CFLAGS += -I$(LIBNL)/include
    #  LIBS += -L$(LIBNL)/lib
    # You can leave out the 'sudo make install' if you don't want 
    # to install hostapd or overwrite your system hostapd.
    make && sudo make install
    cd ../..
  10. Build compat-wireless & install it

    cd compat-wireless-2009-02-21
    make && sudo make install
  11. Configure hostapd

    At this point, you're ready to configure hostapd. I've not yet taken the time to write out a good guide for this, because it's been done. The only thing that is likely to change between other guides and your config are the following settings:


    Hostapd is the best way to test your interface. Just configure hostapd with auth_algs=1 (which means open system) and wpa=0 (which means no wpa encryption at all) for testing. iwconfig can not be used to set a mac80211 interface to master mode (see FAQ Entry for why).

  12. Notes & Addendums

    1. ath9k notes

      802.11n support can be configured in the appropriate section of hostapd.conf, here's the config I'm currently using for my ath9k device, listed as: Atheros AR5416 MAC/BB Rev:2 AR2133 RF Rev:81


      the ht_capab shown here is based on a combination of voodoo and the output of iw list, and may or may not be accurate as I don't yet have any other 802.11n devices to test with

    2. iwconfig wlan0 mode master fails

      This is failure by design. The mac80211 stack does not contain the required components to run in master mode by itself (as far as I understand, correct me if I'm wrong). Rather than let users set it to master mode and not have it work, it tells you that the operation is not supported. You could try doing something like:

      host@domain$ sudo iw phy phy0 interface add wlan0 type ap
      See http://wireless.kernel.org/RTFM-AP.
      but you'll notice that it just sends you to a link, which will eventually lead you back to here. If you REALLY want to try adding an AP interface (although not usable) without using hostapd (which handles doing this on it's own) you can do:
      host@domain$ sudo iw phy phy0 interface add wlan0 type __ap
      but that won't actually get you closer to using it as an Access Point. With mac80211, you NEED hostapd for any sort of functional access point.

Do not feel obligated to donate. Donations won't make me more likely to update the guide or attempt to solve any issues. I have a full time job and am only adding this as it has actually been requested. I won't complain if people do donate though, haha.