Tag Archives: configuration

Hostapd configuration for a 802.11n AP with ath9k

At home I have a good cable internet access but the router/modem combo that my ISP provides includes wireless G (54Mbit/s) AP and a fastEthernet switch (100 Mbit/s).

So when I bought my new server, I was planning to use it as an upgrade for both my wired and wireless networks. The HP microserver has 2 low profile PCIex slots so I bought a cheap gigabit ethernet card and a cheap 150Mbit/s atheros chipset based wifi card :

  • TP-Link – TL-WN781ND – Carte WiFi N PCI express – 150Mbps (14€)
  • TP-Link – Carte réseau Gigabit PCI-Express 1x – Chipset RealTek – TG-3468 (13€)

Installation on Debian is easy, I always use the ISO installer that includes the binary blobs. You should find indications easily on Google anyway.

wlan0 and eth1 on my server are bridged. My ISP’s router is the DHCP server, serving addresses on 192.168.0.0/24

The desktop computer has 2 interfaces: 1 is connected to the router with DHCP, the other is connected to the server’s eth0 with static ips on another private addressing.

So the configuration on the Microserver is limited to bridging 2 interfaces and configuring hostapd.

I took most of the information I needed from that link: http://forum.doozan.com/read.php?2,6300

Here is my /etc/hostapd/hostapd.conf :

# if you want to bridge the onboard eth0 and the wireless USB adapter’s wlan0, this should work
interface=wlan0
bridge=br0
# this is the driver that must be used for ath9k and other similar chipset devices
driver=nl80211
# yes, it says 802.11g, but the n-speeds get layered on top of it
hw_mode=g
# this enables the 802.11n speeds and capabilities … You will also need to enable WMM for full HT functionality.
ieee80211n=1
wmm_enabled=1

# self-explanatory, but not all channels may be enabled for you – check /var/log/messages for details
channel=1
# also, make sure you survey your 2.4GHz environment, and find some uncluttered/uncrowded channels

# adjust to fit your location
country_code=FR
# Here is the authoritative list of countries:
# http://www.iso.org/iso/country_codes/iso_3166_code_lists/country_names_and_code_elements.htm

# let your AP broadcast the settings that agree with the above-mentioned regulatory requirements per country
ieee80211d=1
# adjust to fit your preference
ssid=yourssid
# this is how I set mine up – works perfectly for iPhone, Mac OS X (SnowLeopard) & Linux
auth_algs=3
wpa=3
wpa_passphrase=yourpassword
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
macaddr_acl=0
# these have to be set in agreement w/ channel and some other values… read hostapd.conf docs

# here I’m using 40MHz channels to try and maximize my throughput
ht_capab=[HT40][SHORT-GI-40][RX-STBC1]
# … these can be tuned to specific capabilities per device/chipset
# IIUC, this enables reauthentication for clients, so the passphrase doesn’t have to be re-entered
eap_reauth_period=360000000
# … my understanding… 3600 seconds = 1 hr, so your device would have to reauthenticate if it rejoined after 1 hr
# I have mine set quite a bit higher than 3600 seconds… so that my iPhone doesn’t ask me to type in the password
# frequently…
# makes the SSID visible and broadcasted
ignore_broadcast_ssid=0

And for the bridging, here is my /etc/network.interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# Interface vers le routeur et internet
auto eth1
iface eth1 inet static
address 192.168.0.4
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1

# Interface vers le pc fixe pour transferts rapides
auto eth0
iface eth0 inet static
address 10.0.0.1
netmask 255.255.255.0
network 10.0.0.0
broadcast 10.0.0.255

# Interface wifi pour AP
iface wlan0 inet static
address 192.168.0.3
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1

# Interface bridge
auto br0
iface br0 inet static
bridge_ports eth1 wlan0
address 192.168.0.2
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
up /sbin/ifconfig br0 up
post-up /bin/sleep 10 ; /usr/sbin/hostapd -B /etc/hostapd/hostapd.conf
pre-down /usr/bin/killall hostapd
down /sbin/ifconfig br0 down

The post-up and pre-down take care of switching on and off the wireless AP as soon as the bridge is up/down.