Configuring wifi access point on laptop with hostapd

3

4

I basically trying to configure a linux laptop as a wifi router which other laptops and mobiles can connect to and then I can manipulate the traffic on for some network traffic testing (with lower bandwidths and caps etc.)

My hostapd config file is,

interface=wlan0
driver=nl80211
ssid=atest
hw_mode=g
channel=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=1234567890
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

but hostapd always fails, with -d option i see this,

random: Trying to read entropy from /dev/random
Configuration file: /etc/hostapd/hostapd.conf
nl80211: interface wlan0 in phy phy0
rfkill: initial event: idx=1 type=2 op=0 soft=1 hard=0
rfkill: initial event: idx=2 type=1 op=0 soft=0 hard=0
nl80211: Using driver-based off-channel TX
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame match - hexdump(len=2): 04 0a
nl80211: Failed to register Action frame processing - ignore for now
nl80211: Add own interface ifindex 4
nl80211: Set mode ifindex 4 iftype 3 (AP)
nl80211: Failed to set interface 4 to mode 3: -95 (Operation not supported)
nl80211: Interface already in requested mode - ignore error
nl80211: Create interface iftype 6 (MONITOR)
nl80211: New interface mon.wlan0 created: ifindex=16
nl80211: Add own interface ifindex 16
BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bits)
nl80211: Regulatory information - country=00
nl80211: 2402-2472 @ 40 MHz
nl80211: 2457-2482 @ 20 MHz
nl80211: 2474-2494 @ 20 MHz
nl80211: 5170-5250 @ 40 MHz
nl80211: 5735-5835 @ 40 MHz
nl80211: Added 802.11b mode based on 802.11g information
Completing interface initialization
Mode: IEEE 802.11g  Channel: 1  Frequency: 2412 MHz
nl80211: Set freq 2412 (ht_enabled=0 sec_channel_offset=0)
nl80211: Failed to set channel (freq=2412): -16 (Device or resource busy)
Could not set channel for kernel driver
wlan0: Unable to setup interface.
Flushing old station entries
Could not connect to kernel driver.
Deauthenticate all stations
nl80211: Remove interface ifindex=16
netlink: Operstate: linkmode=0, operstate=6
nl80211: Set mode ifindex 4 iftype 2 (STATION)

Any help with getting this to work would be very much appreciated.

Bootstrapper

Posted 2014-02-12T15:50:28.780

Reputation: 133

Answers

4

(from https://stackoverflow.com/a/22845597 )

It appears that the problem is that hostapd 2.1 is now exiting on an an error it had previously ignored. This is reproducible on Ubuntu desktop versions, as the resource (WLAN) is busy.

If one turns off the programs that are accessing the resource, hostapd has a chance to grab it and work.

In Ubuntu desktop 14.04 beta, a solution is to turn off the programs that are using the wlan in question.

This worked for me:

sudo nmcli nm wifi off
sudo rfkill unblock wlan

then hostapd can start normally from command line. Of course, if you want hostapd to start on boot you must insure that the network manager is not grabbing the resource ahead of time.

e3495026

Posted 2014-02-12T15:50:28.780

Reputation: 41

I will leave this comment only for the sake of note, that this has helped me, cause the answer is unaccepted – user907860 – 2014-06-16T14:09:48.380

2

I had the same problem, running pidora 2014 (Fedora 20 remix for Raspberry Pi). The answer is basically the same as the other two given here: wpa_supplicant was running which prevented hostapd from using the device.

But in case someone else finds it useful, here is the procedure I used to resolve it.

In my case, wpa_supplicant was being started by NetworkManager, which is a daemon used on most modern linux distros to control the network. While it works well in a desktop environment, it does not seem to support AP configuration, and constantly re-spawned wpa_supplicant even when I tried to manually stop it.

The solution was to disable the NetworkManager service and enable the "legacy" network service, which uses simple init scripts to control the network interfaces:

sudo systemctl disable NetworkManager.service 
sudo systemctl enable network.service

After this hostapd started and worked correctly.

harmic

Posted 2014-02-12T15:50:28.780

Reputation: 140

1

Hostapd is failing to set the channel on the netcard via the nl80211 driver:

Mode: IEEE 802.11g  Channel: 1  Frequency: 2412 MHz
nl80211: Set freq 2412 (ht_enabled=0 sec_channel_offset=0)
nl80211: Failed to set channel (freq=2412): -16 (Device or resource busy)

The error code is an indication that something else is using the device so the channel change is disallowed - perhaps wpa_supplicant is running in the background?

Dominic Gifford

Posted 2014-02-12T15:50:28.780

Reputation: 146

-1

Use systemctl --force stop wpa_supplicant.service, then start hostapd v2.1 as normal.

Kevin Padoa

Posted 2014-02-12T15:50:28.780

Reputation: 1

Welcome to Super User. Your answer could use improvement by explaining why/how your solution fixes/addresses the OPs question. Thanks for contributing.

– I say Reinstate Monica – 2015-08-24T02:10:32.043