4

I'm trying to setup a Wireless Access Point with hostapd, however the AP is never visible after starting hostapd service.

Raspberry has two wireless interfaces of the same brand and model (RTL8192CU), however I'm only trying to use one with hostapd, the other one is used to connect Raspberry to my router for running SSH and configuring the device.

I don't know the reason for this problem. See the following configuration files and command output I think relevant in this situation.

Starting hostapd manually in verbose mode outputs the following.

$ hostapd -dd -B /etc/hostapd/hostapd.conf

random: Trying to read entropy from /dev/random
Configuration file: /etc/hostapd/hostapd.conf
rfkill: initial event: idx=0 type=1 op=0 soft=0 hard=0
nl80211: Supported cipher 00-0f-ac:1
nl80211: Supported cipher 00-0f-ac:5
nl80211: Supported cipher 00-0f-ac:2
nl80211: Supported cipher 00-0f-ac:4
nl80211: Supported cipher 00-0f-ac:6
nl80211: Using driver-based off-channel TX
nl80211: interface wlan-ap in phy phy0
nl80211: Set mode ifindex 4 iftype 3 (AP)
nl80211: Failed to set interface 4 to mode 3: -19 (No such device)
nl80211: Could not configure driver mode
nl80211: Remove monitor interface: refcount=0
netlink: Operstate: ifindex=4 linkmode=0 (kernel-control), operstate=6 (IF_OPER_UP)
nl80211: Set mode ifindex 4 iftype 2 (STATION)
nl80211: Failed to set interface 4 to mode 2: -19 (No such device)
nl80211 driver initialization failed.
hostapd_interface_deinit_free(0xb7b0e9f0)
hostapd_interface_deinit_free: num_bss=1 conf->num_bss=1
hostapd_interface_deinit(0xb7b0e9f0)
hostapd_bss_deinit: deinit bss wlan-ap
hostapd_cleanup(hapd=0xb7b0f5f8 (wlan-ap))
hostapd_free_hapd_data: Interface wlan-ap wasn't started
hostapd_interface_deinit_free: driver=(nil) drv_priv=(nil) -> hapd_deinit
hostapd_interface_free(0xb7b0e9f0)
hostapd_interface_free: free hapd 0xb7b0f5f8
hostapd_cleanup_iface(0xb7b0e9f0)
hostapd_cleanup_iface_partial(0xb7b0e9f0)
hostapd_cleanup_iface: free iface=0xb7b0e9f0

It seems the interface wlan-ap doesn't exist. However ifconfig and iwconfig both disagree as you will see further bellow.

/etc/hostapd/hostapd.conf

interface=wlan-ap
ssid=My_AP
hw_mode=g
channel=6
auth_algs=1
wmm_enabled=0

/etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

# Hostapd interface
auto wlan-ap
iface wlan-ap inet static
    address 192.168.200.1
    netmask 255.255.255.0

# Wlan interface
allow-hotplug wlan-connector
iface wlan-connector inet manual
    wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf    
# Network settings.
iface HomeNetwork inet static
    address 192.168.0.211
    network 255.255.255.0
    gateway 192.168.0.1
    dns-nameservers 8.8.8.8 8.8.4.4

$ ifconfig wlan-ap

Link encap:Ethernet  HWaddr *************
BROADCAST MULTICAST  MTU:1500  Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000 
RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

$ iwconfig wlan-ap

unassociated  Nickname:"<WIFI@REALTEK>"
Mode:Auto  Frequency=2.412 GHz  Access Point: Not-Associated   
Sensitivity:0/0  
Retry:off   RTS thr:off   Fragment thr:off
Encryption key:off
Power Management:off
Link Quality:0  Signal level:0  Noise level:0
Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
Tx excessive retries:0  Invalid misc:0   Missed beacon:0

$ dmesg | grep rtl

[    6.701824] usbcore: registered new interface driver rtl8192cu
[    6.712255] rtl8192cu 1-1.5:1.0 wlan-connector: renamed from wlan1
[    6.748025] rtl8192cu 1-1.3:1.0 wlan-ap: renamed from wlan0

These interfaces are of the same model. I'm using wlan-ap for hostapd, and wlan-connector to connect to my router for the solo purpose of running SSH and configuring the device to function as an Wlan AP.

$ iw wlan-ap info

command failed: No such device (-19)

I tried to use iw to find if the interface supports AP/Master mode. But to my disbelieve, iw couldn't find hostapd interface, for that matter it can't also find the interface I'm using to run these commands through SSH.

It makes no sense, on one side it can find the interface on another it can't.

Something wrong with my configuration or is it a drive issue?

Using the latest Raspbian version (headless), fully updated:

$ uname -r

4.1.18-v7+
Fábio Antunes
  • 149
  • 2
  • 4
  • 14
  • Have you changed the line #DEAMON_CONF="" to DEAMON_CONF="/etc/hostapd/hostapd.conf" in /etc/default/hostapd ? I'm also wondering if you might have some problems with your static ip ... which raspian version is installed on your pi? – scherzkrapferl Mar 05 '16 at 18:06
  • Yes, I've changed the `DEAMON_CONF` var to point towards the hostapd.conf file. Running the latest version of Raspbian fully updated. – Fábio Antunes Mar 05 '16 at 18:11
  • Ok, so have you checked your static ip? – scherzkrapferl Mar 05 '16 at 18:14
  • Yes, `wlan-ap` has a static IP (see above), Confirmed with `ifconfig`. Also, to make sure that `udhcpd` service was working correctly, I temporary changed `eth0` to a static IP almost like I was going to use `eth0` instead of `wlan-ap` and configured `udhcpd.conf` to assign IP addresses to devices connected on `eth0`, and it assigned a correct IP to my laptop when plugged via ethernet... In a nutshell, I confirmed DHCP would work for any new connected device. The problem is `hostapd` or the device drive, I can't see the new wireless access point configured in `hostapd.conf` – Fábio Antunes Mar 05 '16 at 18:22
  • Can you please post also the wpa-supplicant.conf file, as that also controls the wifi interfaces. – Bungee75 Mar 07 '16 at 07:45

2 Answers2

3

For that particular card you need a special version of hostapd

Download the software from this URL: RTL8192CU.

The file is called "Linux Kernel 2.6.18~2.6.38 and Kernel 3.0.8..." version: 3.4.4_*

Then run these commands:

unzip RTL8192xC_USB_linux_*.zip
tar zxvf RTL8188C_8192C_USB_linux_*/wpa_supplicant_hostapd/wpa_supplicant_hostapd-0.8_rtw_*.tar.gz
cd wpa_supplicant_hostapd-0.8_*/hostapd/
make
sudo cp hostapd hostapd_cli /usr/local/sbin/

For Raspberry Pi you might want to change the line that says CFLAGS=... to CFLAGS=-MMD -Os in the Makefile.

There's a nice full explanation here: How to create an accesspoint using a RealTek 8192cu Usb Wifi Dongle.

Greenonline
  • 2,448
  • 4
  • 18
  • 33
nwaltham
  • 311
  • 1
  • 6
  • Greetings. That's exactly what I was going for. Compiling a new driver for `RTL8192CU` based on the original Realtek driver ported to GitHub, according to the explanation link provided, the driver I'm trying to compile is the same as showcased. I will try it in a few hours after I solve some issues with the compilation, do you know why we need a special version of `hostapd`? Shouldn't the driver be enough? – Fábio Antunes Mar 07 '16 at 14:13
  • I'm not totally sure, but I think its because the card/ kernel driver doesn't directly support mac80211 which is used by the stock hostapd to control the access point. https://wireless.wiki.kernel.org/en/developers/documentation/mac80211 – nwaltham Mar 07 '16 at 14:20
  • Did you get this to work? – nwaltham Mar 08 '16 at 19:56
  • Note: Awarding bounty in 23h. – Fábio Antunes Mar 09 '16 at 00:56
  • Very good news. Glad you got it going! – nwaltham Mar 09 '16 at 09:21
0

you say you have updated to the latest raspbian release, if this is JESSIE then you are not supposed to edit the network/interface file.

How do I set up networking/WiFi/static IP address?. See this link.

Steve Gale
  • 31
  • 1
  • Greetings. I've used the headless version of Raspbian, "Raspbian Jessie Lite" as written on [RaspberryPi.Org](https://www.raspberrypi.org/downloads/raspbian/). Manually editing `/etc/network/interfaces` file for configuring network settings is quite common. On a side note, I can use `ifconfig` and I see all devices have used the settings as outlined in the file. – Fábio Antunes Mar 07 '16 at 01:39
  • I am the author of the link and this does not say "you are not supposed to edit the network/interface file". The tutorial is aimed at use of the default `dhcpcd`. If you are not using this there are many different ways of setting up networking. – Milliways Mar 09 '16 at 08:51