WLAN Access Point with Atheros (ath5k) Chipset on Linux


The system environment

WLAN miniPCI card TP-LINK WN360G in an Alix1 (AMD Geode LX cpu) with OpenSuSE 11.2
A similar setup with Compex miniPCI card WLM54GP23 (Atheros AR2413 802.11bg), bought at pcengines was also successful (openSUSE 10.3, madwifi driver, hostapd 0.6.9).

Install the hostapd daemon

hostapd from the distro is outdated (0.5.10) and comes without init script. So I installed it from sources from the hostapd home site.

hostapd-0.6.10 (latest stable release at time of this writing) did not work (error message: "Could not set DTIM period for kernel driver", see bug 344). I installed development release hostapd-0.7.1 instead.

The ath5k is a mac80211-based driver so a prerequisit for hostapd is the nl80211 library which is in the libnl-devel package of OpenSuSE. The standard kernel should be ok.

To build hostapd download and extract the source tarball and change to the hostapd directory. Make a copy of defconfig to .config and edit according to your needs. My .config looks like this:

CONFIG_DRIVER_HOSTAP=y
CONFIG_DRIVER_NL80211=y
CONFIG_IAPP=y
CONFIG_RSN_PREAUTH=y
CONFIG_PEERKEY=y
CONFIG_EAP=y
CONFIG_EAP_MD5=y
CONFIG_EAP_TLS=y
CONFIG_EAP_MSCHAPV2=y
CONFIG_EAP_PEAP=y
CONFIG_EAP_GTC=y
CONFIG_EAP_TTLS=y
CONFIG_PKCS12=y
CONFIG_IPV6=y

Then do a

> make
> sudo make install

Create a configuration file /etc/hostapd.test.conf, mine looks like this:

interface=wlan0
driver=nl80211
logger_syslog=-1
logger_syslog_level=2
logger_stdout=-1
logger_stdout_level=2
debug=0
dump_file=/tmp/hostapd.dump
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
ssid=MyWLAN
country_code=CH
hw_mode=g
channel=1
beacon_int=100
dtim_period=2
max_num_sta=255
rts_threshold=2347
fragm_threshold=2346
macaddr_acl=0
auth_algs=3
ignore_broadcast_ssid=0
wme_enabled=1
wme_ac_bk_cwmin=4
wme_ac_bk_cwmax=10
wme_ac_bk_aifs=7
wme_ac_bk_txop_limit=0
wme_ac_bk_acm=0
wme_ac_be_aifs=3
wme_ac_be_cwmin=4
wme_ac_be_cwmax=10
wme_ac_be_txop_limit=0
wme_ac_be_acm=0
wme_ac_vi_aifs=2
wme_ac_vi_cwmin=3
wme_ac_vi_cwmax=4
wme_ac_vi_txop_limit=94
wme_ac_vi_acm=0
wme_ac_vo_aifs=2
wme_ac_vo_cwmin=2
wme_ac_vo_cwmax=3
wme_ac_vo_txop_limit=47
wme_ac_vo_acm=0
eapol_key_index_workaround=0
eap_server=0
own_ip_addr=127.0.0.1
wpa=2
wpa_passphrase=**censored**

Create an init script /etc/init.d/hostapd for hostapd:

# Provides:             hostapd
# Required-Start:       $network
# Required-Stop:
# Default-Start:        2 3 5
# Default-Stop:         0 1 6
# Short-Description:    hostapd daemon
# Description:          Starts hostapd on startup
### END INIT INFO


# Check for missing binaries (stale symlinks should not happen)
hostapd_BIN=/usr/local/bin/hostapd
test -x $hostapd_BIN || { echo "$hostapd_BIN not installed";
        if [ "$1" = "stop" ]; then exit 0;
        else exit 5; fi; }


# Check for existence of needed config file
hostapd_CONFIG=/etc/hostapd.test.conf
test -r $hostapd_CONFIG || { echo "$hostapd_CONFIG not existing";
        if [ "$1" = "stop" ]; then exit 0;
        else exit 6; fi; }

hostapd_PID=/var/run/hostapd.pid

. /etc/rc.status
rc_reset


case "$1" in
  start)
        echo -n "Starting hostapd... "
        eval startproc $hostapd_BIN -B -P $hostapd_PID $hostapd_CONFIG
        rc_status -v
        ;;
  stop)
        echo -n "Stopping hostapd... "
        killproc -TERM $hostapd_BIN
        rc_status -v
        ;;
  restart)
        $0 stop
        $0 start
        rc_status
        ;;
  status)
        echo -n "Checking for service Hostapd "
        #test -d $hostapd_PID && echo "Hostapd running." || echo "Hostapd not running."
        checkproc $hostapd_BIN
        rc_status -v
        ;;
  *)
        echo "Usage: $0 {start|stop|restart|status}"
        exit 1
        ;;
esac
rc_exit

DHCP server

Setup a DHCP server to assign ip addresses and the like to connecting clients.
My /etc/dhcpd.conf looks like this:

option domain-name "my.domain";
option domain-name-servers ns1.provider, ns2.provider;

default-lease-time 600;
max-lease-time 7200;
ddns-update-style none; ddns-updates off;
authoritative;
log-facility local7;

subnet 192.168.0.0 netmask 255.255.255.0 {
  range 192.168.0.2 192.168.0.254;
  option domain-name-servers ns1.provider, ns2.provider;
  option domain-name "";
  option routers 192.168.0.1;
  option broadcast-address 192.168.0.255;
  default-lease-time 600;
  max-lease-time 7200;
}

In /etc/sysconfig/dhcpd set the interface the dhcpd listens to:

DHCPD_INTERFACE="wlan0"

Configure the runlevel boot scripts for hostapd and dhcpd to start on boot.

Firewall/Routing

Setup SuSEfirewall for routing between eth0 and wlan0.

Links to some interesting articles on this topic

line
linux logo Powered by Apache
line
This site maintained by:
lukas.zimmermann@unibas.ch
My public PGP key
last updated: 2010-02-17 Valid CSS! Valid XHTML 1.0 Strict