Linux – Hostapd requires manual restart for devices to connect

hostapdlinuxnetworkingUbuntuwireless-networking

I am currently setting up a WiFi hotspot for the padres using their NAS with WiFi card.

Setup: Ubuntu 13.10

Hostapd is bridged with eth0 (br0), and works great if manually restarted

sudo service hostapd restart

* Stopping advanced IEEE 802.11 management hostapd [ OK ]

* Starting advanced IEEE 802.11 management hostapd [ OK }

However, upon reboot the SSID is visible, but when trying to connect I am presented with (authentication error / incorrect password) from wireless devices.

If the above command is executed over ssh/local terminal, then all devices connect perfectly.

In order to work around this, I tried adding a delayed cron job to restart the service;

@reboot sleep 30; /fixscripts/hostapdstart.sh

I even wrote a script to stop the service and start it 60 seconds later in a similar format to above. (I believe the scripts did execute, because the SSID would dissapear, and reappear 60 seconds later).

However as per the original issue wifi devices were still presented with the authentication errors, and as before if I log on and manually restart the service it works!

Below is my hostapd.conf;

ssid=Caprica

wpa_passphrase=mypassword

interface=wlan0

bridge=br0

auth_algs=3

channel=7

driver=nl80211

hw_mode=g

ieee80211n=1

wmm_enabled=1

logger_stdout=-1

logger_stdout_level=2

max_num_sta=5

rsn_pairwise=CCMP

wpa=2

wpa_key_mgmt=WPA-PSK

wpa_pairwise=TKIP CCMP

Best Answer

The fix below 'worked' for me, however devices would disconnect after a short period of time. Ultimately I clean installed Ubuntu 12.04 and all seems to work fine.

  1. Remove the hostapd service from the rcX files to prevent the service from automatically starting;

    sudo update-rc.d -f hostapd remove

  2. Provide a Cron Job to start the service shortly after boot

  3. Then provide a Cron job to restart the service shortly after starting

To modify Cron file;

sudo crontab -e

Here are the Cron Jobs I added;

@reboot sleep 10; /fixscripts/hostapdstart.sh
@reboot sleep 25; /fixscripts/hostapdrestart.sh

This starts the service 10 seconds after boot, and then restarts it 15(25-10) seconds later.

Related Question