3

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

Georgi Stoyanov
  • 790
  • 4
  • 16
  • 41
  • 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: https://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
  • @oh.dae.su I have added an `[EDIT]` at the end of my post with the output of the `iw list` command. – Georgi Stoyanov Nov 12 '18 at 06:41
  • 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.conf`using 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 09:31
  • @oh.dae.su I will try tonight, I am currently at work. – Georgi Stoyanov Nov 12 '18 at 09:40
  • @oh.dae.su this actually solved my problem, but now every time I try to connect to the AP I connect and then at the IP assignment the AP disappears. – Georgi Stoyanov Nov 13 '18 at 11:00
  • 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? https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md – oh.dae.su Nov 13 '18 at 21:21
  • 1) I have added a second `EDIT2` to my thread, 2) I am connecting initially to the AP, I see that the network is connected but then when I try to start SpeedTest on my phone connected to WiPi it disconnects me. 3) I have reverted my configuration to the one from your link and 2) is with the new configuration. Is it possible @oh.dae.su that this is due to insufficient power? I have disconnected my SSD from the RPi in any case. – Georgi Stoyanov Nov 14 '18 at 19:23
  • Just curious @oh.dae.su, is your nickname coming from the movie Oldboy? – Georgi Stoyanov Nov 14 '18 at 19:25
  • Yes it is the main character from the movie Oldboy! Regarding your issue: Interesting. I have not come across the lacking randomness error before. A quick google search seems to suggest that people with the same issue were able to make it work, when either 1) commenting out the line driver=nl80211 in hostapd.conf or 2) installing `rng-tools` to get a better source of entropy. Please see here: https://www.raspberrypi.org/forums/viewtopic.php?t=143749 – oh.dae.su Nov 14 '18 at 20:25
  • I have upgraded the kernel with `sudo raspi-update`, installed the `rng-tools` checked the service status and commented the driver line in the `hostapd.conf` file and then killed all processes and restarted the `hostapd` but as soon as my phone connected it crashed again with the same error and the AP disappeared – Georgi Stoyanov Nov 14 '18 at 20:51
  • then I am also out of ideas. sorry – oh.dae.su Nov 14 '18 at 21:07
  • I have actually deleted the channel line in the configuration and now the AP endured slightly more, it crashed after the second Speedtest. I have also added a 3rd EDIT to the post with the debug information, but unfortunately, it didn't help me much to localize the problem. Anyway thanks for your help @oh.dae.su – Georgi Stoyanov Nov 14 '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 https://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
  • I will give it a try tomorrow and see if it is going to work. Thanks for sharing this link with me @AlexOnLinux – Georgi Stoyanov Nov 16 '18 at 18:10

1 Answers1

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.

Michael Prokopec
  • 2,202
  • 7
  • 21