Linux host as a WiFi access point with WPA2

Below you may find a quick recipe to turn a computer running Linux equipped with an Atheros-based WiFi card into a WiFi access point with WPA2-PSK security.

It is a slightly modified configuration presented on Radek Karpowicz’s blog. In particular, I needed to add the line responsible for not caching MAC adresses (brctl setageing br0 0) to achieve correct behavior. Without it the “AP” acted weird, i.e. for some time everything was working fine and then the WiFi-connected hosts couldn’t reach the rest of the network – the only solution (an unacceptable one of course in the longer perspective) was to ping any LAN address directly from the “AP”. I don’t know, maybe I don’t understand something, maybe I have misconfigured something or maybe it’s simply some error in hostapd or the madwifi drivers. All in all, I haven’t came across similar problems since adding that line to the script.

  • hostapd.conf:
    interface=ath0
    bridge=br0
    driver=madwifi
    # show verbose output
    logger_syslog=-1
    logger_syslog_level=2
    logger_stdout=-1
    logger_stdout_level=2
    debug=4
    dump_file=/tmp/hostapd.dump
    ctrl_interface=/var/run/hostapd
    ctrl_interface_group=0
    ssid=OurSSID
    eapol_key_index_workaround=0
    eap_server=0
    wpa=2
    wpa_key_mgmt=WPA-PSK
    wpa_pairwise=CCMP
    wpa_passphrase=ourPreSharedKey
    
  • ap-init.sh:
    wlanconfig ath0 destroy
    wlanconfig ath0 create wlandev wifi0 wlanmode ap
    iwconfig ath0 channel channel_number
    brctl addbr br0
    brctl addif br0 ath0
    brctl addif br0 eth0
    brctl setageing br0 0
    ifconfig ath0 0.0.0.0
    ifconfig eth0 0.0.0.0
    ifconfig br0 IP_address
    hostapd hostapd.conf
    
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s