2

I am trying to set an AP on a Raspberry Pi 3 using an external USB WiFi card and hostapd and dsnmasq. I have managed to achieve it using the internal WiFi card but when I try to switch to my external one I got the following error:

$ sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
nl80211: Could not configure driver mode
nl80211: deinit ifname=wlan1 disabled_11b_rates=0
nl80211 driver initialization failed.
wlan1: interface state UNINITIALIZED->DISABLED
wlan1: AP-DISABLED 
hostapd_free_hapd_data: Interface wlan1 wasn't started

I believe it is because by default the hostapd is using nl80211 driver. This is the output of lsusb - Bus 001 Device 004: ID 148f:3072 Ralink Technology, Corp. RT3072 Wireless Adapter. And this is the output of lshw

  *-network:1
       description: Wireless interface
       physical id: 3
       bus info: usb@1:1.4
       logical name: wlan1
       serial: 98:3f:9f:24:a2:00
       capabilities: ethernet physical wireless
       configuration: broadcast=yes driver=rt2800usb driverversion=4.14.71-v7+ firmware=0.36 ip=10.100.100.254 link=no m
ulticast=yes wireless=IEEE 802.11

So apparently this card is using the rt2080usb driver but when I try to put it inside the hostapd.conf and start manually the hostapd I got the following error:

$ sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
Line 3: invalid/unknown driver 'rt2080usb'
1 errors found in configuration file '/etc/hostapd/hostapd.conf'
Failed to set up interface with /etc/hostapd/hostapd.conf
Failed to initialize interface

And this is my hostapd.conf file:

interface=wlan1
ssid=WiPi
driver=rt2080usb
hw_mode=g
ieee80211n=1
wmm_enabled=1
channel=4
macaddr_acl=0
auth_algs=3
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=wifipasswordhere
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
ht_capab=[HT20][SHORT-GI-20]

[EDIT] This is the output of the iwconfig command:

wlan1     IEEE 802.11  ESSID:off/any  
          Mode:Managed  Access Point: Not-Associated   Tx-Power=20 dBm   
          Retry short  long limit:2   RTS thr:off   Fragment thr:off
          Power Management:off

wlan0     IEEE 802.11  ESSID:off/any  
          Mode:Managed  Access Point: Not-Associated   Tx-Power=31 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:on

And this is the output of the iw list command:

valid interface combinations:
         * #{ AP, mesh point } <= 8,
           total <= 8, #channels <= 1

[EDIT 2] This is the output when I start the 'hostapd':

$ sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf 
Configuration file: /etc/hostapd/hostapd.conf
Using interface wlan1 with hwaddr 98:3f:9f:24:a2:00 and ssid "WiPi"
random: Only 16/20 bytes of strong random data available from /dev/random
random: Not enough entropy pool available for secure operations
WPA: Not enough entropy in random pool for secure operations - update keys later when the first station connects
wlan1: interface state UNINITIALIZED->ENABLED
wlan1: AP-ENABLED 

And this is the output of iwconfig:

wlan1     IEEE 802.11  Mode:Master  Tx-Power=20 dBm   
          Retry short  long limit:2   RTS thr:off   Fragment thr:off
          Power Management:off

And this is the hostapd log when I try to connect to my essid WiPi and run speedtest:

$ Configuration file: /etc/hostapd/hostapd.conf
Using interface wlan1 with hwaddr 98:3f:9f:24:a2:00 and ssid "WiPi"
wlan1: interface state UNINITIALIZED->ENABLED
wlan1: AP-ENABLED 
wlan1: STA 94:65:2d:d4:e0:5b IEEE 802.11: authenticated
wlan1: STA 94:65:2d:d4:e0:5b IEEE 802.11: associated (aid 1)
wlan1: AP-STA-CONNECTED 94:65:2d:d4:e0:5b
wlan1: STA 94:65:2d:d4:e0:5b RADIUS: starting accounting session 5BEC735C-00000000
wlan1: STA 94:65:2d:d4:e0:5b WPA: pairwise key handshake completed (RSN)
wlan1: AP-STA-DISCONNECTED 94:65:2d:d4:e0:5b
Failed to set beacon parameters
wlan1: INTERFACE-DISABLED 
wlan1: INTERFACE-ENABLED 
Failed to set beacon parameters
wlan1: INTERFACE-DISABLED 
wlan1: INTERFACE-ENABLED 
Failed to set beacon parameters
handle_probe_req: send failed

[EDIT 3]: I have run the hostapd in debug mode sudo hostapd -dd -P /run/hostapd.pid -B -f /tmp/hostapd.log /etc/hostapd/hostapd.conf set to on and uploaded the log file to pastebin

  • 2
    One comment: You should not put driver=rt2080usb into the config file. This field is not intended for the device driver. The list of available options for that field can be found in this hostapd.conf documentation: w1.fi/cgit/hostap/plain/hostapd/hostapd.conf – oh.dae.su Nov 11 '18 at 20:29
  • Two questions: 1) does the wlan1 interface work in managed mode, i.e are you able to connect to an AP? 2) what does iw list report under "valid interface combinations" for your WiFi adapter? – oh.dae.su Nov 11 '18 at 20:54
  • 2
    Ok, so master mode is supported. One idea you could try: Kill all wpa-supplicant and hostapd instances running with sudo killall wpa_supplicant and sudo killall hostapd. Then try again with sudo /usr/sbin/hostapd /etc/hostapd/hostapd.confusing your original hostapd.conf file (with driver=nl80211). One reason where you get the error message you see, is that the interface is already used by another process. – oh.dae.su Nov 12 '18 at 9:31
  • 1
    1) What does iwconfig say after this happens? Are you still in master mode, or back to managed mode? 2) Is the dissappearance of the AP really related to the connection attempt or does it simply happen a constant period after starting the AP? 3) Did you try with a more basic hostapd.conf, e.g. the one from the RPi? raspberrypi.org/documentation/configuration/wireless/… – oh.dae.su Nov 13 '18 at 21:21
  • 1
    It's not an answer to your question but it might help you to solve your project. I used my PI3 as AP the whole last week. Instead of inventing the wheel i just graped this nice tool github.com/oblique/create_ap . After installing it's dependencies it worked like charm. I used two external cards, one Alfa and one tp-link usb wifi adapter. – AlexOnLinux Nov 16 '18 at 17:15
0

This should help: https://www.ibm.com/developerworks/library/l-wifiencrypthostapd/index.html

https://wiki.gentoo.org/wiki/Hostapd

auth_algs=1 #Limit it to wpa

wpa=1 #To limit it to wpa

Also: You have ieee80211n=1 set and hw_mode=g set try setting ieee80211n=0 or remove that option and see if that helps.

If you are not going to use the internal card at all I would blacklist the internal card and then configure the external one for use with hostapd or if a GUI is installed then just simply use the setup ap option in the connection manager to share your wired connection. Make sure all the files you modified other then the one that controls hostapd is back to original if you try any of the above options.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.