2

I'm having a lot of trouble getting hostapd to create an access point upon system boot when it is configured to run in IEEE 802.11a (5 GHz). Running it manually from the command line or in IEEE 802.11g (2.4 GHz) works just fine - only when I try to create the AP on boot does it fail.

First, let me give you some details.

System environment

  • Debian 8.9 (Jessie) 64-Bit (see below for uname output)
  • Wifi adapter is an Azurewave AW-NE785H with Atheros AR9280/AR5B95 chipset (supports both 802.11a and 802.11g, is AP-ready)

uname -a yields: Linux HOSTNAME 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2+deb8u2 (2017-06-26) x86_64 GNU/Linux

What I'm trying to do

I am trying to create an access point (AP) that runs in 802.11a mode (5 GHz) and that is started when the system boots.

What the problem is

The problem is that the AP is not created when I boot the system, although there is an init script in /etc/init.d that is actually run upon boot. What's even weirder is that when I try to run the AP in IEEE 802.11g mode (2.4 GHz), everything works just fine, the AP comes up when the system is booted. The same applies for manually starting hostapd, either using service hostapd start or hostapd <my-config-file>.

What I found out so far/logs/config

Here's my hostapd config file (/etc/hostapd/hostapd.cfg):

interface=wlan0
driver=nl80211

country_code=DE
ieee80211n=1
ieee80211ac=1
wmm_enabled=1

ssid=MYSSID
hw_mode=a
channel=acs_survey
macaddr_acl=0
auth_algs=1

ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=supersecretpassphrasehere
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

dump_file=/tmp/hostapd.dump

logger_syslog=-1
logger_syslog_level=2
logger_stdout=-1
logger_stdout_level=2

Here's my init script (/etc/init.d/hostapd):

#!/bin/sh

### BEGIN INIT INFO
# Provides:     hostapd
# Required-Start:   $remote_fs $network $syslog
# Required-Stop:    $remote_fs $network $syslog
# Default-Start:    2 3 4 5
# Default-Stop:     0 1 6
# Short-Description:    Advanced IEEE 802.11 management daemon
# Description:      Userspace IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP
#           Authenticator
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON_SBIN=/usr/sbin/hostapd
DAEMON_DEFS=/etc/default/hostapd
DAEMON_CONF=/etc/hostapd/hostapd.cfg
NAME=hostapd
DESC="advanced IEEE 802.11 management"
PIDFILE=/run/hostapd.pid
LOGFILE=/var/log/hostapd_log

[ -x "$DAEMON_SBIN" ] || exit 0
[ -s "$DAEMON_DEFS" ] && . /etc/default/hostapd
[ -n "$DAEMON_CONF" ] || exit 0

DAEMON_OPTS="-dd -f $LOGFILE -B -P $PIDFILE $DAEMON_OPTS $DAEMON_CONF"

. /lib/lsb/init-functions

case "$1" in
  start)
    log_daemon_msg "Starting $DESC" "$NAME"
    start-stop-daemon --start --oknodo --quiet --exec "$DAEMON_SBIN" \
        --pidfile "$PIDFILE" -- $DAEMON_OPTS >/dev/null
    log_end_msg "$?"
    ;;
  stop)
    log_daemon_msg "Stopping $DESC" "$NAME"
    start-stop-daemon --stop --oknodo --quiet --exec "$DAEMON_SBIN" \
        --pidfile "$PIDFILE"
    log_end_msg "$?"
    ;;
  reload)
    log_daemon_msg "Reloading $DESC" "$NAME"
    start-stop-daemon --stop --signal HUP --exec "$DAEMON_SBIN" \
        --pidfile "$PIDFILE"
    log_end_msg "$?"
    ;;
  restart|force-reload)
    $0 stop
    sleep 8
    $0 start
    ;;
  status)
    status_of_proc "$DAEMON_SBIN" "$NAME"
    exit $?
    ;;
  *)
    N=/etc/init.d/$NAME
    echo "Usage: $N {start|stop|restart|force-reload|reload|status}" >&2
    exit 1
    ;;
esac

exit 0

hostapd log file

As you can see I told hostapd to write to /var/log/hostapd_log. I tried to raise the AP upon boot once more and here's what I read from the log file (the whole thing was almost 500 lines):

  1. hostapd uses the expected config file (/etc/hostapd/hostapd.cfg)
  2. hostapd sets the country/regulatory domain to DE as expected
  3. hostapd starts automatic channel selection as expected (channel=acs_survey).
    • Something seems to go wrong here. The driver (nl80211) reports a failed frame command (ret=-22 (Invalid argument))
  4. 5 ACS survey scans are performed without any error messages
  5. ACS fails with the message below, then that's it.

Here's the log messages when ACS fails:

ACS: Trying survey-based ACS
ACS: Unable to collect survey data
ACS: All study options have failed
Interface initialization failed
wlan0: interface state ACS->DISABLED
wlan0: AP-DISABLED 
ACS: Possibly channel configuration is invalid, please report this along with your config file.
ACS: Failed to start
wlan0: AP-DISABLED 
wlan0: Deauthenticate all stations
[cut some lines here]
hostapd_free_hapd_data: Interface wlan0 wasn't started
[cut some more lines here]
Interface wlan0 disabled

When I run service hostapd start (without touching anything), the AP comes up and I can see that ACS does its job just fine (it selects channel 40).

Google

Of course I googled a lot for a solution to my problem. I think I narrowed it down to it being some kind of issue with the boot process itself or system services interfering with each other. The only hint I got from that is to disable wpa_supplicant (the hint I found stated that the person solved the problem by disabling wpa_supplicant and other interfering services. Sadly, they never mentioned the other services they disabled.

I ran systemctl status wpa_supplicant and got the following output:

● wpa_supplicant.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)

So I guess it's not active anyway?

TL;DR

Why does hostapd fail to create an access point when configured to run in 802.11a mode and started on boot but succeeds to create it after booting is completed and the exact same command is executed manually? What do I have to do in order to achieve what I'm trying to do?

Has anyone out there successfully created an AP like I am trying to create? Any hints?

If any further details are required, I'd be happy to provide them.

Thanks a lot in advance

1 Answer 1

0

Looks like a bug in hostapd. I'm using the following settings for hostapd service to restart it automatically:

[Service]
Restart=on-failure
RestartSec=30
# hostapd fails with exit code 0 when ACS is enabled
RestartForceExitStatus=0

(can be added with systemctl edit hostapd)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .