rubenrp
Posts: 9
Joined: Wed Dec 02, 2015 6:05 pm

Re: Pi 3 as wiireless client and wireless AP?

Mon Mar 28, 2016 5:30 pm

Anthony, thank you so much for all your work - it's extremely helpful. Unfortunately, I see the same:
Failed to create interface mon.wlan1: -95 (Operation not supported)
wlan1: Could not connect to kernel driver
error message that nulldev reported. After that message appears, I can connect to the RPi3 as an access point, but it no longer connects to the local WiFi network. I've run your steps on a fresh install of Raspbian Jessie 2016-3-18, and the result is the same.

Any thoughts you might have as to what might be causing the problem, and why your (and stopgaplabs') RPi3 are behaving differently from mine and nulldev's would be greatly appreciated.

anthony19114
Posts: 23
Joined: Fri Mar 25, 2016 11:25 pm

Re: Pi 3 as wiireless client and wireless AP?

Mon Mar 28, 2016 6:01 pm

Well what is wlan1? None of the instructions mentioned wlan1? Are you making the virtual interface called wlan1 instead of uap0? wlan* are dedicated interfaces for non virtual devices I believe this might be the issue.

rubenrp
Posts: 9
Joined: Wed Dec 02, 2015 6:05 pm

Re: Pi 3 as wiireless client and wireless AP?

Mon Mar 28, 2016 10:50 pm

Oops - sorry - I copied and pasted part of nulldev's reply, and did not notice that it read wlan1 instead of uap0. My error message actually reads:
Failed to create interface mon.uap0: -95 (Operation not supported)
uap0: could not connect to kernel driver
Again, many thanks for any thoughts you might have.

anthony19114
Posts: 23
Joined: Fri Mar 25, 2016 11:25 pm

Re: Pi 3 as wiireless client and wireless AP?

Mon Mar 28, 2016 10:58 pm

Mine says this also, but it works.. It should say AP ENABLED. Perhaps set your channel the same in the hostapd.conf?
So your AP on uap0 and wifi on wlan0 use the same channel.

FirstRasPi
Posts: 1
Joined: Mon Apr 04, 2016 7:47 am

Re: Pi 3 as wiireless client and wireless AP?

Mon Apr 04, 2016 8:10 am

Hi, im new here and im not really sure what i am doing.

I got my first Pi a week ago with the idea that i would make it into a Tor AP that i can use it at home and when im in unsecured WiFi connections like internet cafe's etc. The Pi 3 with its much better hardware and built in Wireless chip made me ecstatic and i payed for it as soon as it was released.

However i have been stuck on this enigma for more than a week than, i have not been able to create an actual AP no matter what guide i followed.

First ones for older Pi 2 were faulty and my Pi couldnt find the nl80211 driver so i tried other one to no avail.
Then i found this guide https://frillip.com/using-your-raspberr ... h-hostapd/

it all went well and i managed to set up the AP but i could not connect to the internet. But after messing around with the IP addresses in the guide i managed to get a VERY slow internet connection that would drop.

Then i found this guide and it went well but again i cant connect to the internet!

Please can someone help on this, im starting to lose my mind here.

Does it matter what IP address i use because many use IP Addresses that are not like my router at home which is 192.168.0.1

Any help would be appreciated.

nulldev
Posts: 23
Joined: Sat Mar 05, 2016 3:39 am

Re: Pi 3 as wiireless client and wireless AP?

Fri Apr 08, 2016 3:35 am

anthony19114 wrote:Configuring 1 AP + Many wireless connections with One wireless network card. :lol:
sudo bash for a root prompt :geek:

apt-get install hostapd dnsmasq

Uncomment and edit these lines in /etc/dnsmasq.conf

interface=lo,uap0

no-dhcp-interface=lo,wlan0

dhcp-range=192.168.2.100,192.168.2.200,12h



Edit: /etc/hostapd/hostapd.conf

Add: Change ssid and wpa_passphrase also. (this one is plaintext).

interface=uap0
ssid=pipi
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=0123456789
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP


Edit and add to: /etc/network/interfaces

auto uap0
iface uap0 inet static
address 192.168.2.1
netmask 255.255.255.0



Edit a new file:

pico /usr/local/bin/hostapdstart

add:

iw dev wlan0 interface add uap0 type __ap
service dnsmasq restart
sysctl net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -s 192.168.2.0/24 ! -d 192.168.2.0/24 -j MASQUERADE
ifup uap0
hostapd /etc/hostapd/hostapd.conf


Change permissions on /usr/local/bin/hostapdstart

chmod 667 /usr/local/bin/hostapdstart

Edit and add line to: /etc/rc.local

hostapdstart >1&

OR just type hostapdstart if you want to see details or if you do not want it to start automatically.

Ignore next step if wlan0 is up and working.
Please configure this prior.. :

Add to /etc/network/interfaces
remove all other wlan0 anything references. then add:

auto wlan0
iface wlan0 inet dhcp
wpa-ssid ssidofAP
wpa-psk a03133ea3333471b0d33dbd1b2b19233294649968537c35904eb3389a7df65ba

Replace the psk with yours generated by typing: wpa_passphrase ssidofAP yourWPApass


Your complete /etc/network/interfaces should look like this but with different wpa-psk and wpa-ssid:

auto wlan0
iface wlan0 inet dhcp
wpa-ssid ssidofAP
wpa-psk a03133ea3333471b0d33dbd1b2b19233294649968537c35904eb3389a7df65ba

auto uap0
iface uap0 inet static
address 192.168.2.1
netmask 255.255.255.0

This worked perfectly. Thanks everyone for the help.
Do you mind if I include these instructions in my project? And repost them on my project page once it is created?

anthony19114
Posts: 23
Joined: Fri Mar 25, 2016 11:25 pm

Re: Pi 3 as wiireless client and wireless AP?

Fri Apr 08, 2016 3:38 am

You can use them for anything you want. I'd be interested in knowing more about your project also.

tespin
Posts: 5
Joined: Wed Jan 27, 2016 5:18 am

Re: Pi 3 as wiireless client and wireless AP?

Tue Apr 12, 2016 6:28 am

Hey all, been trying to figure this same problem out on my own for a while now and have luckily stumbled into this thread. I've tried a few different suggestions of the thread but none seem to be working for me; most recent one is anthony19114's suggestion, but at the end of it, I get errors saying:
Could not read interface uap0 flags: No such device
nl80211: Driver does not support authentication/association or connect
Could not read interface uap0 flags: No such device
nl80211 driver initialization failed
hosted_free_hapd_data: Interface uap0 wasn't started
Does anybody seem to have a definitive walkthrough for getting a Pi 3 to connect to the internet with its built-in wifi then broadcast that with a wifi dongle? Or might anybody be able to point me in the right direction or offer some advice?

Thanks!

anthony19114
Posts: 23
Joined: Fri Mar 25, 2016 11:25 pm

Re: Pi 3 as wiireless client and wireless AP?

Tue Apr 12, 2016 6:31 am

Remove the nl80211 line from your hostapd.conf

tespin
Posts: 5
Joined: Wed Jan 27, 2016 5:18 am

Re: Pi 3 as wiireless client and wireless AP?

Tue Apr 12, 2016 8:06 am

Hi Anthony! Thanks for the quick response. I don't think that'll do me much good, being that I don't even have a line in my hostapd.conf file for the driver:
Screen Shot 2016-04-12 at 3.02.18 AM.png
Screen Shot 2016-04-12 at 3.02.18 AM.png (10.7 KiB) Viewed 20777 times
Please let me know if there is anything more you'd like to see to help me diagnose this problem!

anthony19114
Posts: 23
Joined: Fri Mar 25, 2016 11:25 pm

Re: Pi 3 as wiireless client and wireless AP?

Tue Apr 12, 2016 12:17 pm

If your using two wifi cards change uap0 to the interface you want the AP to broadcast on.. This uap0 in the instructions here is for using only the built in wifi with no second wifi card. So perhaps in this tutorial you can replace uap0 with wlan1 in all the configuration and don't use the iw command to make a virtual interface since you have a second physical device.

tespin
Posts: 5
Joined: Wed Jan 27, 2016 5:18 am

Re: Pi 3 as wiireless client and wireless AP?

Tue Apr 12, 2016 4:03 pm

That worked for me up to a point. I am able to connect to wifi via wlan0, and wlan1 is broadcasting my network. I get feedback from the Pi as I connect via my phone. However, it seems like it's unable to connect fully; it only has that spinning circle and my phone displays that it's connected to 4G rather than the wifi.

Also, when I enter:
sudo service hostapd start
sudo service dnsmasq start
the hotspot disappears. I feel like I'm getting close. What might be wrong?

anthony19114
Posts: 23
Joined: Fri Mar 25, 2016 11:25 pm

Re: Pi 3 as wiireless client and wireless AP?

Tue Apr 12, 2016 4:16 pm

Two wireless cards configuration:

sudo bash for a root prompt



apt-get install hostapd dnsmasq

Uncomment and edit these lines in /etc/dnsmasq.conf

interface=lo,wlan1

no-dhcp-interface=lo,wlan0

dhcp-range=192.168.2.100,192.168.2.200,12h


Edit: /etc/hostapd/hostapd.conf

Add: Change ssid and wpa_passphrase also. (this one is plaintext).

interface=wlan1
ssid=pipi
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=0123456789
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Edit and add to: /etc/network/interfaces

auto wlan1
iface wlan1 inet static
address 192.168.2.1
netmask 255.255.255.0


Edit a new file:

pico /usr/local/bin/hostapdstart

add:

service dnsmasq restart
sysctl net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -s 192.168.2.0/24 ! -d 192.168.2.0/24 -j MASQUERADE
ifup wlan1
hostapd /etc/hostapd/hostapd.conf

Change permissions on /usr/local/bin/hostapdstart

chmod 667 /usr/local/bin/hostapdstart

Edit and add line to: /etc/rc.local

hostapdstart >1&

OR just type hostapdstart if you want to see details or if you do not want it to start automatically.

Ignore next step if wlan0 is up and working.
Please configure this prior.. :

Add to /etc/network/interfaces
remove all other wlan0 anything references. then add:

auto wlan0
iface wlan0 inet dhcp
wpa-ssid ssidofAP
wpa-psk a03133ea3333471b0d33dbd1b2b19233294649968537c35904eb3389a7df65ba

Replace the psk with yours generated by typing: wpa_passphrase ssidofAP yourWPApass


Your complete /etc/network/interfaces should look like this but with different wpa-psk and wpa-ssid:

auto wlan0
iface wlan0 inet dhcp
wpa-ssid ssidofAP
wpa-psk a03133ea3333471b0d33dbd1b2b19233294649968537c35904eb3389a7df65ba

auto wlan1
iface wlan1 inet static
address 192.168.2.1
netmask 255.255.255.0

Reboot!

petter.oj.norman
Posts: 14
Joined: Wed Jun 17, 2015 6:41 pm

Re: Pi 3 as wiireless client and wireless AP?

Thu May 26, 2016 4:58 pm

Thanks for the tuto Anthony (AP and station on single chip), it works great!
Next up is the singel channel challenge ;)
As of now I have to define into hostapd.conf the channel to use for the AP. And this channel must be the same as whatever channel of ap the station connects to. This work exactly one out of four times at my home where I run multiple accesspoints with same ssid but different channels to cover the area.
And it will be a problem when I connect to public hotspots as well.

Any idéas on how to work around this.

Petter...

FreshMint
Posts: 1
Joined: Thu Jun 02, 2016 1:05 am

Re: Pi 3 as wiireless client and wireless AP?

Thu Jun 02, 2016 1:07 am

anthony19114 wrote:If anyone experiences network performance issues it can be remedied if you use the same wpa password on AP and virtual interface and/or same channel.
Have you been able to get wpa_supplicant to join OTHER networks AFTER hostapd is up and running with the virtual network?
I've noticed once the pi connects to the host network, you cannot change to another network.

Great work by the way.

petter.oj.norman
Posts: 14
Joined: Wed Jun 17, 2015 6:41 pm

Re: Pi 3 as wiireless client and wireless AP?

Thu Jun 02, 2016 1:22 pm

FreshMint wrote:
anthony19114 wrote:If anyone experiences network performance issues it can be remedied if you use the same wpa password on AP and virtual interface and/or same channel.
Have you been able to get wpa_supplicant to join OTHER networks AFTER hostapd is up and running with the virtual network?
I've noticed once the pi connects to the host network, you cannot change to another network.

Great work by the way.
To me it seem a bad idéa to use same ssid on ap and client. This would be to ask for it to connect to self. But what if you try "priority" in the network tags in wpa_supplicant.conf. Higher number gives higher priority.

Like this

Code: Select all

network={
        bssid=00:50:17:31:1a:11
        ssid="YourSSID"
        psk="your-secret-key"
        scan_ssid=1
        proto=RSN
        key_mgmt=WPA-PSK
        group=CCMP TKIP
        pairwise=CCMP TKIP
        priority=5
}
Petter...

georg3003
Posts: 7
Joined: Tue Jun 28, 2016 3:26 pm

Re: Pi 3 as wiireless client and wireless AP?

Wed Jun 29, 2016 9:11 am

anthony19114 wrote:If anyone experiences network performance issues it can be remedied if you use the same wpa password on AP and virtual interface and/or same channel.
Hi,

I have the pi3 with Jessie and this isnT working perfectly I have a second Wlandevice with a 5dbi antenna from adafruit.

wlan0 is loosing IP address and once hostapd went sleeping

the powermanagement remains on, on dev uap0.


AND the best it happened, that my correct credentials for wireless were not accepted, because of wrong key.

I thought already maybe I have to use the same key. maybe then it's working better.


I will have a try.

amuxie
Posts: 4
Joined: Wed May 18, 2016 6:34 am

Re: Pi 3 as wiireless client and wireless AP?

Thu Jul 07, 2016 3:06 am

hi,all

when i add the hostapdstart >1& to rc.local, it can't work run,

show 1 log file is:
Failed to create interface mon.uap0: -95(Operation not supported)

but if i run the command on the shell, it can work.

what's the reason?

thanks in advance!

Samuele
Posts: 1
Joined: Sat Jul 09, 2016 2:52 pm

Re: Pi 3 as wiireless client and wireless AP?

Sat Jul 09, 2016 3:01 pm

petter.oj.norman wrote:Thanks for the tuto Anthony (AP and station on single chip), it works great!
Next up is the singel channel challenge ;)
As of now I have to define into hostapd.conf the channel to use for the AP. And this channel must be the same as whatever channel of ap the station connects to. This work exactly one out of four times at my home where I run multiple accesspoints with same ssid but different channels to cover the area.
And it will be a problem when I connect to public hotspots as well.

Any idéas on how to work around this.

Petter...
Hi, anyone has found a solution to this problem? I have the same issue too. If in hostapd I use a different channel from the one of the access point, nothing works (and the client pc with windows freeze). The raspberry will be used in a roaming configuration, with channel and ssid changing every day. At the moment the only solution I found is to add a usb wifi card.

Thanks.

barry914
Posts: 48
Joined: Sat Aug 20, 2016 7:40 pm

Re: Pi 3 as wiireless client and wireless AP?

Sat Dec 03, 2016 6:40 pm

After struggling with this B3 problem for weeks and just about giving up, I found two hints here that were indispensable. One was needing to have both the physical interface WLAN0 and the virtual interface uap0 on the same channel, which seemed counterintuitive until it sunk in that a physical interface could not simultaneously operate on two different channels. The second, a bit more perplexing, is finding WLAN0 would disconnect when uap0 came up, but only when run from rc.local on boot. When hostapdstart was invoked from the command line WLAN0 retained its IP and kept its association with my wireless router. I eventually added a 2 second sleep before invoking hostapd, the last line in that script. I still see a short-lived ad-hoc network with my router's SSID come up before my AP comes up, according to my WLAN monitor app on my phone. I have no idea why that is happening. Anyway, it reliably comes up on boot now and both the eth0 and WLAN0 interfaces are active, and I can access apps running on the AP with or without an internet connection, which is exactly the behavior I wanted. The one thing I would like to add (if it's not there already but I don't know how to use it) is a DHCP client (I think) to make the AP's and other devices' hostnames routable on its subnet instead of having to use IPs. Can anyone point me in the right direction?

Here's my /etc/network/interfaces file. Note I am using the original reference to wpa_supplicant and also note the power save option I added. It seems the on-board interface does go into power save mode by default.

Code: Select all

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
    post-up iw dev $IFACE set power_save off

allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

auto uap0
iface uap0 inet static
address 192.168.2.1
netmask 255.255.255.0

bkoblenz
Posts: 1
Joined: Fri Dec 02, 2016 4:07 pm

Re: Pi 3 as wiireless client and wireless AP?

Sat Dec 03, 2016 9:19 pm

I really like the way this is presented and think I am very close, but alas things do not work.

I get a dhcp address from wlan0 on a 192.168.1.0\24 network, set up uap0 and the dnsmasq and hostapd config files.

I set up uap0, get dnsmasq running and ifup uap0 and everything is fine at that point.

When I start hostapd I do get an access point that I can connect to the 192.168.2.0/24 network, but the act of starting hostapd (before even connecting) causes wlan0 to drop its connection to my router effectively isolating my system and whatever is connected to the access point. ifconfig wlan0 shows no inet addr.

I have seen some references to wpa_supplicant bug and some linux bridging bug but I am not sure what to do/where to look.

I am running versions 2.3 of hostapd and wpa_supplicant. and uname -r returns: 4.4.11-v7+

Help would be most appreciated.

thanks

User avatar
Cancelor
Posts: 757
Joined: Wed Aug 28, 2013 4:09 pm
Location: UK

Re: Pi 3 as wiireless client and wireless AP?

Mon Dec 05, 2016 9:46 am

Many have tried and many have failed.

I wonder if there is someone who could make a ready made and working image so that we could all download and use it?
Can't find the thread you want? Try googling : YourSearchHere site:raspberrypi.org

afan
Posts: 1
Joined: Tue Jan 31, 2017 8:13 am

Re: Pi 3 as wiireless client and wireless AP?

Wed Feb 01, 2017 5:42 am

Thanks to anthony19114 and everybody else for providing a solution.

I tried anthony's setup verbatim at first, and, as others reported, got access point working, but no connection over wlan0.

As barry914 summed it up, "One was needing to have both the physical interface WLAN0 and the virtual interface uap0 on the same channel". And the wlan0 channel is not something you can control on your Raspberry Pi — this is the channel that your home Wi-Fi router broadcasts on. So in my case, it was channel 8, so after editing channel setting in /etc/hostapd/hostapd.conf to read `channel=8` and rebooting RPi I was able to get both AP and wlan0 working.

So if one wants to somehow automate the process of booting AP and wlan0, they need to boot with AP turned off, wait for wlan0 to connect, get the channel number from `iwlist channel`, update /etc/hostapd/hostapd.conf (or create a temporary config file) and finally run `hostapdstart` script to start AP. If at boot time wlan0 fails to connect to any network, then AP can use any channel.

The logic above can probably be integrated into the hostapdstart script itself. Hope this helps.

nulldev
Posts: 23
Joined: Sat Mar 05, 2016 3:39 am

Re: Pi 3 as wiireless client and wireless AP?

Fri Feb 24, 2017 6:02 am

Hi,
I have been running into some issues with this setup. I have my rp3 setup as earlier outlined. The built in wifi is running as a client on my home network and running as an 'ap'.
I can connect to the ap with my laptop.
I also have apache running on the rp3. I can access webpages I have hosted the rp3 by connecting to the ap with my laptop and then entering the ipaddress of the ap in the browser followed by the page name.
For example 192.168.2.1/index.html. While connected I can also pass through the rp3 and get to the internet ... www.google.com for example.

While connected I can ssh from the laptop to the rp3. The issue comes up here because my ssh connection keeps seeming to freeze pretty often. I can get maybe one or two commands to complete before it happens. Sometimes it will disconnect completely, . I lose the ssh connection and the connection to the ap over wifi, but sometimes ssh just freezes and then it will resume.. I will be typing, then the putty session stops responding, then it will 'wake up' and the letters I have typed all appear at once.

When it is 'frozen' I can ping it and usually get either 50% or greater dropped packets or 50% of the pings will be in the several hundred ms range.

I have made sure the ap is broadcasting on the same channel as my home wifi I have made the passwords the same, and I have upgraded the kernel.

Any tips on helping troubleshoot this issue would be greatly appreciated. One thing that came to mind was maybe checking that my home wifi and the ap were both using the same flavor of wifi -- 'g' or 'n' ..But I'm not sure that is worth looking at or how to tell which the pie is connecting to my home router through.

Anyone got any ideas on how to troubleshoot this? which logs should I be checking?
Thanks!

barry914
Posts: 48
Joined: Sat Aug 20, 2016 7:40 pm

Re: Pi 3 as wiireless client and wireless AP?

Fri Feb 24, 2017 6:29 am

I'm not sure this is related, but I have no problem connecting to the AP from my laptop, but my Android phone won't stay connected. It gets an IP, stays connected for a bit and then disconnects. I get an error message that says it received an unknown SSID. I think when the phone gets the router's SSID it freaks out (that's a technical term), but my Windows machine is more robust and can deal with this.

Return to “Networking and servers”