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

Pi 3 as wiireless client and wireless AP?

Sat Mar 05, 2016 4:18 am

Hi,
I just ordered my Pi 3 and am looking forward to its arrival. This will be my first one
I read a write up here:
http://makezine.com/2016/02/28/eben-upt ... erry-pi-3/
Where the following comment is made:
"It seems likely, given the chipset, that the Raspberry Pi should be able to operate in both Access Point mode and client mode simultaneously. In other words, it can get its internet connection by joining on a wireless network, while simultaneously providing a second network as an access point to a ‘cloud’ of sensors. Both firewalling the sensor network away from the network that has laptops and games consoles, and humans, and extending the reach of the original network to inaccessible places."

That sounds like what I am looking for. I would like to run a webserver on the pi hosting a small site. I would like the pi would be connected to the internet via wifi connection, simultaneously I would to like connect to the pi locally with a phone or pc over wifi. While connected to the pi from the phone I would like to be able to request mysite.pi and it be served from the websever running on the pi and also be able to request google.com and have that be served from the internet.

Is something like this possible?
What might the /etc/network/interfaces look like?
I assume I will end up with a configuration similar to this tutorial https://learn.adafruit.com/downloads/pd ... -point.pdf
but it is using Ethernet to connect to the internet and broadcasting as an access point over wifi. I would like to do everything over wifi only.
What is the best way in network terms to describe what I am trying to achieve? I am not a network engineer.

Thanks in advance.

pipuppy
Posts: 95
Joined: Fri Aug 24, 2012 12:51 pm

Re: Pi 3 as wiireless client and wireless AP?

Sat Mar 05, 2016 2:43 pm

Hi,

I was looking for much the same information as you and to cut a l-o-n-g story short the answer appears to be "yes" you can use the new R3 in AP mode. I asked a similar question in a duplicate posting on this forum (general and networking areas) and received a very helpful pointer from DirkS as follows...

by DirkS » Sat Mar 05, 2016 2:57 pm
Yes, can be done. See view ... 70#p919980 for (partial) info...
***** end quote *****

I hope this helps. I have not had time to test this yet myself but I am optimistic it should work. The rest of the setting-up depends on your requirements.

Thanks in advance wrote:
That sounds like what I am looking for. I would like to run a webserver on the pi hosting a small site. I would like the pi would be connected to the internet via wifi connection, simultaneously I would to like connect to the pi locally with a phone or pc over wifi. While connected to the pi from the phone I would like to be able to request mysite.pi and it be served from the websever running on the pi and also be able to request google.com and have that be served from the internet.
********** end quote *************

I have a small stand-alone wireless webserver running on a pi2 (or is it a pi1 ??) but so far I have never been able to get it to serve both my pages and still connect to the WWW at the same. Though to be fair I have never really tried as this was not something I wanted. All I remember is that while setting-up the wireless satand-alone server I come to a point at which my server starts working in AP mode but at the expense of the WWW wireless connection to my BB router.

I should add that I am largely "clueless" about such matters but decided to respond to your post to save you searching. I hope this is somewhat helpful in pointing you in the right direction.

Regards,

pipuppy

pipuppy
Posts: 95
Joined: Fri Aug 24, 2012 12:51 pm

Re: Pi 3 as wiireless client and wireless AP?

Sat Mar 05, 2016 3:19 pm

Hi again,

I have been posting "dud" links (sorry), try this one, it should work....

viewtopic.php?t=137932&p=920070#p919980

Regards,

pipuppy

pipuppy
Posts: 95
Joined: Fri Aug 24, 2012 12:51 pm

Re: Pi 3 as wiireless client and wireless AP?

Sun Mar 06, 2016 2:35 pm

Hi again,

Just a short follow-up to my last posting and the linked information on Raspi3 AP mode.

I can confirm that the information given is correct and that if followed the R3 will work in AP mode as (in my case) a stand-alone wireless server.

The only problem I had was that after re-booting the pi my hot-spot ceased to be fully functional. The problem was traced/fixed to the "interfaces" configuration file located in the "/etc/network" directory.

The line which reads "#allow-hotplug wlan0" is commented out by default. Removing the "#" at the start of the line corrected the problem and the R3 stand-alone-server now functions correctly after re-boot every time.

Regards,

pipuppy

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

Re: Pi 3 as wiireless client and wireless AP?

Sun Mar 06, 2016 5:54 pm

Thanks for your replies.
I have a seen a config on a linux box similar to:
wlanconfig ath0 create wlandev wifi0 wlanmode sta
wlanconfig ath1 create wlandev wifi0 wlanmode ap

Which seems to be what I'm looking for. One wireless interface to serve as both access point and station. I am not proficient enough to take that and make it work on pi. m not even sure how to google it. I have seen the term vap (virtual acess point) and even vwap mentioned.

I will check out the links you posted.
thanks

paulv
Posts: 564
Joined: Tue Jan 15, 2013 12:10 pm
Location: Netherlands

Re: Pi 3 as wiireless client and wireless AP?

Mon Mar 07, 2016 7:35 am

I'm pretty sure you cannot do both with one wireless adapter.
You need two. One for the clients, and one for the server.
It has been done before.
Google is your friend.

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

Re: Pi 3 as wiireless client and wireless AP?

Mon Mar 07, 2016 4:47 pm

I have made some progress in that I now know that you can describe this configuration as:
Concurrent AP/Station mode operation on the same device. This is a step forward since I didn't know they were called devices nor did I know sta stood for 'station'.

I also found the MadWiFi driver supports this with what they call VAP's - a bit of a misnomer since it does not have to be in AP mode.

I found the man page for the configuration tool for these 'VAPs'

http://linux.die.net/man/8/wlanconfig

Now I need to find out if the pi 3 can do this and if so how to set it up.
Does anyone know if the wifi built into the Pi 3 is compatible with the MadWiFi driver?

Maybe I can reach out to writer of the makezine article and be pointed in the right direction re. configuration.

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

Re: Pi 3 as wiireless client and wireless AP?

Tue Mar 08, 2016 1:06 am

More information to share. Looks like the MadWiFi driver is for Atheros chipsets. I have not found a driver for the broadcom BCM43438 that supports simultaneous ap+sta on one device but I'm still looking. Maybe the pi3 supports it out of the box?
If any of you have a Pi 3 already it would be great if you would post the output of this command:

iw list

It appears that the TL-WN722N dongle will work with MadWiFi and the pi and should give the functionality I'm seeking if I can't get the built in wifi to do it.
That conclusion is based on this post: http://raspberrypi.stackexchange.com/qu ... t-ap-modes

Its interesting that the article speculated that the built in wifi in the pi 3 should support this. I'm still waiting on my Pi. No idea when it may ship btw.
If you have one already, where did you order from that you got your pi3 so fast :)


glynhudson
Posts: 9
Joined: Fri Mar 18, 2016 12:35 am

Re: Pi 3 as wiireless client and wireless AP?

Fri Mar 18, 2016 10:34 am

Yes, RasPi3 should support client + AP mode at the same time:

See section at the bottom:

valid interface combinations:
* #{ IBSS, managed, AP } <= 2, #{ P2P-client, P2P-GO } <= 1, #{ P2P-device } <= 1,
total <= 3, #channels <= 2
Device supports scan flush.

iw list
Wiphy phy0
max # scan SSIDs: 10
max scan IEs length: 2048 bytes
Retry short limit: 7
Retry long limit: 4
Coverage class: 0 (up to 0m)
Device supports roaming.
Device supports T-DLS.
Supported Ciphers:
* WEP40 (00-0f-ac:1)
* WEP104 (00-0f-ac:5)
* TKIP (00-0f-ac:2)
* CCMP (00-0f-ac:4)
* CMAC (00-0f-ac:6)
Available Antennas: TX 0 RX 0
Supported interface modes:
* IBSS
* managed
* AP
* P2P-client
* P2P-GO
* P2P-device
Band 1:
Capabilities: 0x1020
HT20
Static SM Power Save
RX HT20 SGI
No RX STBC
Max AMSDU length: 3839 bytes
DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 16 usec (0x07)
HT TX/RX MCS rate indexes supported: 0-7
Bitrates (non-HT):
* 1.0 Mbps
* 2.0 Mbps (short preamble supported)
* 5.5 Mbps (short preamble supported)
* 11.0 Mbps (short preamble supported)
* 6.0 Mbps
* 9.0 Mbps
* 12.0 Mbps
* 18.0 Mbps
* 24.0 Mbps
* 36.0 Mbps
* 48.0 Mbps
* 54.0 Mbps
Frequencies:
* 2412 MHz [1] (20.0 dBm)
* 2417 MHz [2] (20.0 dBm)
* 2422 MHz [3] (20.0 dBm)
* 2427 MHz [4] (20.0 dBm)
* 2432 MHz [5] (20.0 dBm)
* 2437 MHz [6] (20.0 dBm)
* 2442 MHz [7] (20.0 dBm)
* 2447 MHz [8] (20.0 dBm)
* 2452 MHz [9] (20.0 dBm)
* 2457 MHz [10] (20.0 dBm)
* 2462 MHz [11] (20.0 dBm)
Supported commands:
* new_interface
* set_interface
* new_key
* start_ap
* join_ibss
* set_pmksa
* del_pmksa
* flush_pmksa
* remain_on_channel
* frame
* set_channel
* tdls_oper
* start_sched_scan
* start_p2p_device
* crit_protocol_start
* crit_protocol_stop
* connect
* disconnect
Supported TX frame types:
* managed: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* P2P-client: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* P2P-GO: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* P2P-device: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
Supported RX frame types:
* managed: 0x40 0xd0
* P2P-client: 0x40 0xd0
* P2P-GO: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
* P2P-device: 0x40 0xd0
software interface modes (can always be added):
valid interface combinations:
* #{ IBSS, managed, AP } <= 2, #{ P2P-client, P2P-GO } <= 1, #{ P2P-device } <= 1,
total <= 3, #channels <= 2
Device supports scan flush.

stopgaplabs
Posts: 11
Joined: Tue Mar 22, 2016 12:33 am

Re: Pi 3 as wiireless client and wireless AP?

Tue Mar 22, 2016 12:49 am

I'm extremely new here (as can be seen by this post's #) and fairly new to raspberry pi (like 2-3 months) but I've lurked here the whole time.

Just got in the new 3 and am enjoying it. Through this forum and a few others I'm close to getting sta+client going.

Setting up hostapd mostly normally (but change wlan0 to wlan1; change the channel to whatever iwlist shows for wlan0) and then setting up interfaces with wlan1 having whatever default gateway you want for the router then

Code: Select all

sudo iw dev wlan0 interface add wlan1 type __ap
and then

Code: Select all

 sudo hostapd /etc/hostapd/hostapd.conf
starts showing your new network available while still being able to use the client side on wlan0(what I'm communicating with it with to start with.

As I get it cleaned up, I'll start making better step by steps. I just knew that with a little nudge, people with much more *nix skill will have it done in minutes vs. my hours or days.

Thank y'all for a great forum.
Robbie

tharada
Posts: 6
Joined: Wed Mar 23, 2016 9:30 pm

Re: Pi 3 as wiireless client and wireless AP?

Wed Mar 23, 2016 10:16 pm

Does anyone know if it's possible for the access point to use a different channel than the connected network? My Pi 3 refuses to connect to, for example, a network on channel 11 if hostapd is using channel 1. I'd prefer not to install another dongle, nor to reconfigure hostapd on the fly, if it can be avoided. Thanks.

My setup:

Code: Select all

iw dev wlan0 interface add uap0 type __ap
ip addr add 192.168.2.1/24 dev uap0
/etc/hostapd/hostapd.conf:

Code: Select all

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

stopgaplabs
Posts: 11
Joined: Tue Mar 22, 2016 12:33 am

Re: Pi 3 as wiireless client and wireless AP?

Wed Mar 23, 2016 11:31 pm

Does anyone know if it's possible for the access point to use a different channel than the connected network? My Pi 3 refuses to connect to, for example, a network on channel 11 if hostapd is using channel 1. I'd prefer not to install another dongle, nor to reconfigure hostapd on the fly, if it can be avoided. Thanks
I'm reluctant to EVER say something's impossible. I can only speak to what I've been able to do and I haven't been able to do it without finding what channel wlan0 is on

Code: Select all

iwlist channel
and setting the channel variable in hostapd to that channel.

I've read that even if it could, there'd probably be a ton of dropped packets and other issues. Speaking to automating that switch, I don't know the best/right way of doing that yet.

tharada
Posts: 6
Joined: Wed Mar 23, 2016 9:30 pm

Re: Pi 3 as wiireless client and wireless AP?

Wed Mar 23, 2016 11:49 pm

For what it's worth, I don't have this issue on the Utilite, which uses a Marvell 88W8787 chipset, although I don't know if that's an exception or the norm for this sort of hardware.

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

Re: Pi 3 as wiireless client and wireless AP?

Thu Mar 24, 2016 3:07 pm

stopgaplabs wrote:I'm extremely new here (as can be seen by this post's #) and fairly new to raspberry pi (like 2-3 months) but I've lurked here the whole time.

Just got in the new 3 and am enjoying it. Through this forum and a few others I'm close to getting sta+client going.

Setting up hostapd mostly normally (but change wlan0 to wlan1; change the channel to whatever iwlist shows for wlan0) and then setting up interfaces with wlan1 having whatever default gateway you want for the router then

Code: Select all

sudo iw dev wlan0 interface add wlan1 type __ap
and then

Code: Select all

 sudo hostapd /etc/hostapd/hostapd.conf
starts showing your new network available while still being able to use the client side on wlan0(what I'm communicating with it with to start with.

As I get it cleaned up, I'll start making better step by steps. I just knew that with a little nudge, people with much more *nix skill will have it done in minutes vs. my hours or days.

Thank y'all for a great forum.
Robbie
Did you get this working?

stopgaplabs
Posts: 11
Joined: Tue Mar 22, 2016 12:33 am

Re: Pi 3 as wiireless client and wireless AP?

Thu Mar 24, 2016 3:20 pm

Yes, but it still has some issues I haven't figured out yet. After about 3 hours, the ssid I had set up changes its name to the network I'm connected to through wlan0 and pretty much becomes unreachable.

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

Re: Pi 3 as wiireless client and wireless AP?

Thu Mar 24, 2016 3:54 pm

stopgaplabs wrote:Yes, but it still has some issues I haven't figured out yet. After about 3 hours, the ssid I had set up changes its name to the network I'm connected to through wlan0 and pretty much becomes unreachable.

I read the ink you posted. I don't know how to translate that for the pi.
Would these commands work as is?

iw phy phy0 interface add mySta type station
iw phy phy0 interface add myAcc type __ap

Sorry I need so much hand holding.
Ideally I need someone to tell me : TYPE THIS LIST OF COMMANDS

:)

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

Re: Pi 3 as wiireless client and wireless AP?

Thu Mar 24, 2016 3:59 pm

sorry, glynnhudson posted the link

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

Re: Pi 3 as wiireless client and wireless AP?

Thu Mar 24, 2016 5:46 pm

stopgaplabs wrote:Yes, but it still has some issues I haven't figured out yet. After about 3 hours, the ssid I had set up changes its name to the network I'm connected to through wlan0 and pretty much becomes unreachable.
Any chance you could share the configuration?
Sound like you are very close.

stopgaplabs
Posts: 11
Joined: Tue Mar 22, 2016 12:33 am

Re: Pi 3 as wiireless client and wireless AP?

Thu Mar 24, 2016 6:05 pm

Definitely.

I went through the steps here http://www.timokorthals.de/?p=243 pretty much verbatim for setting up between two wifi dongles.

I did

Code: Select all

iwlist channel
to find out what wlan0 was on and used that to change the channel in the hostapd.conf file. Also, you can # out the driver=nl80211 part in that file now.

Actually, there were some issues I had with that file so mine just looks like this now:

Code: Select all

interface=wlan1
#driver=rtl871xdrv
ssid=Cirice
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=bootsiecollins
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
When you do:

Code: Select all

sudo iw dev wlan0 interface add wlan1 type __ap
that will cause wlan1 to come up in access point mode.

and when you do:

Code: Select all

sudo hostapd /etc/hostapd/hostapd.conf
that will cause it to start broadcasting your ssid and allow you to get on there.

It's nowhere near perfect or done. I still have issues with it crapping out on me after a few hours and once that's fixed I'll need to make it run at boot.

stopgaplabs
Posts: 11
Joined: Tue Mar 22, 2016 12:33 am

Re: Pi 3 as wiireless client and wireless AP?

Thu Mar 24, 2016 6:07 pm

I juggled a lot of information and made a lot of changes back and forth as I was trying to figure it out and have yet to start from scratch to make sure I'm not leaving out some key ingredient but if you're not able to do it, I'll try to start over and see what's missing.

I think these were the main things.

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

Re: Pi 3 as wiireless client and wireless AP?

Fri Mar 25, 2016 4:01 am

thanks for your posts.
after the start of hostadp I get this:

Failed to create interface mon.wlan1: -95 (Operation not supported)
wlan1: Could not connect to kernel driver
Using interface wlan1 with hwaddr b8:27:eb:99:5f:78 and ssid "pi"
random: Only 18/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


I am not sure if these messages are important
I can see the broadcasted network, but I never get an ip from it Any suggestion? I saw somewhere saying it may be a clock issue?

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

Re: Pi 3 as wiireless client and wireless AP?

Sat Mar 26, 2016 1:02 am

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

stopgaplabs
Posts: 11
Joined: Tue Mar 22, 2016 12:33 am

Re: Pi 3 as wiireless client and wireless AP?

Sat Mar 26, 2016 6:33 pm

I can confirm that the steps listed above work on a fresh install of raspbian and are a lot less convoluted than the steps I have been working on.

Great job.

Rob

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

Re: Pi 3 as wiireless client and wireless AP?

Sat Mar 26, 2016 7:21 pm

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.

Return to “Networking and servers”