SurferTim
Posts: 1689
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Pi 3 as wiireless client and wireless AP?

Fri Nov 24, 2017 11:46 am

@sora03: I have a working ap and client using two wifi devices with different chipsets on a RPi3.

If you are going to attempt this, I highly recommend using predictable interface names.

JacoFourie
Posts: 87
Joined: Thu Mar 10, 2016 6:51 pm

Re: Pi 3 as wiireless client and wireless AP?

Tue Nov 28, 2017 1:32 pm

SurferTim wrote:
Fri Nov 24, 2017 11:46 am
@sora03: I have a working ap and client using two wifi devices with different chipsets on a RPi3.

If you are going to attempt this, I highly recommend using predictable interface names.
Can you please share your set-up.

SurferTim
Posts: 1689
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Pi 3 as wiireless client and wireless AP?

Tue Nov 28, 2017 1:37 pm

No problem. I have several times. The first order of business is twofold.

1) Does your RPi recognize your wifi dongle?

2) Set your RPi to use predictable interface names.
To use mac based interface names in Stretch
Move or remove /etc/systemd/network/99-default.link
Open /etc/systemd/network/99-default.link with a text editor. (Empty file)
Insert this:

Code: Select all

[Link]
NamePolicy=kernel database onboard slot path mac
MACAddressPolicy=persistent
Reboot

JacoFourie
Posts: 87
Joined: Thu Mar 10, 2016 6:51 pm

Re: Pi 3 as wiireless client and wireless AP?

Thu Nov 30, 2017 7:38 am

Hi. I was talking more about your wireless set-up. Not just the names. How to set-up AP and client on Stretch that works 100%
We want to use the on-board as AP and the dongle as client (if in range of a wifi network)

SurferTim
Posts: 1689
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Pi 3 as wiireless client and wireless AP?

Thu Nov 30, 2017 10:41 am

I use the first example here for my access point. Since I use predictable interface names, I change eth0 and wlan0 to predictable names.
https://github.com/SurferTim/documentat ... s-point.md

Once the access point is working, I set up the client by opening the /etc/wpa_supplicant/wpa_supplicant.conf file and save it as
/etc/wpa_supplicant/wpa_supplicant-wlx<mac address>.conf
Add your network data there.

Add a masquerade for this wifi device.

Code: Select all

sudo iptables -t nat -A  POSTROUTING -o wlx<mac address>  -j MASQUERADE


Reboot. Works every time. If you don't use predictable names, it will work most of the time.

luizalmeida
Posts: 7
Joined: Sun Nov 10, 2013 6:50 pm

Re: Pi 3 as wiireless client and wireless AP?

Wed Dec 13, 2017 2:11 pm

Hi everybody,

I would like to know if someone else has tested it in the new Raspbian release (RASPBIAN STRETCH - 2017-11-29)?
Best regards,

LA

SurferTim
Posts: 1689
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Pi 3 as wiireless client and wireless AP?

Wed Dec 13, 2017 2:14 pm

I've tested the other AP options (standalone and bridged), but not both a client and AP on one interface. I'll get around to it soon.

It shouldn't be a problem. There doesn't seem to be much change as far as networking goes.

luizalmeida
Posts: 7
Joined: Sun Nov 10, 2013 6:50 pm

Re: Pi 3 as wiireless client and wireless AP?

Thu Dec 14, 2017 9:50 am

Hi everyone.

I can confirm that it is working on RASPBIAN STRETCH - 2017-11-29 release.
I just follow the steps in this link (thanks @aqpeeb)
Thank you all.
Best Regards,

LA

Bartgast
Posts: 2
Joined: Wed Jan 24, 2018 10:47 am
Location: Netherlands, The Hague

Re: Pi 3 as wiireless client and wireless AP?

Wed Jan 24, 2018 4:19 pm

@SurferTim

Tim as well here :)

PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

So I have been trying to make it work for a week now, getting to understand more and more, but I did not get any Internet access so far. One of the problems is the dozens of guides i have been working with and losing track of it.
I am trying to achieve the exact same thing as you. However I needed to swap wlan0 and wlan1 since my wlan1 (TP-Link W722N v1.10) was not starting the AP because of driver nl80211 error.
So eventually i had the AP running on wlan0 (onboard wifi) but still no internet.
After reading somemore I noticed you post about not touching /etc/network/interfaces so i started again.

After following all these guides i never was able to access the internet. So my question is as follows; Which part allows access to the internet (i believe the IP tables but as mentioned before, it never worked for me, which can be because i was following older guides for Jessie).

SurferTim
Posts: 1689
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Pi 3 as wiireless client and wireless AP?

Wed Jan 24, 2018 7:27 pm

If you are connecting to the network and getting network settings, the only two things are the masquerade and ipv4 forwarding.
Edit /etc/sysctl.conf and uncomment

Code: Select all

net.ipv4.ip_forward=1
The iptables rule.

Code: Select all

sudo iptables -t nat -A  POSTROUTING -o wlan1 -j MASQUERADE

Bartgast
Posts: 2
Joined: Wed Jan 24, 2018 10:47 am
Location: Netherlands, The Hague

Re: Pi 3 as wiireless client and wireless AP?

Thu Jan 25, 2018 10:39 am

I have been playing around with that as well however so far no luck.

I will try this tonight again and post my code as well. Thanks for the reply!

souviktor
Posts: 1
Joined: Sat Feb 03, 2018 12:21 am

Re: Pi 3 as wiireless client and wireless AP?

Sat Feb 03, 2018 12:33 am

Hi,


FOllowing up on the topic, I used the instructions here:

http://imti.co/post/145442415333/raspbe ... station-ap

I see that on boot up, both uap0 and wlan0 is active. waln0 connects to my hoem wifi connection.
On the uap0, something weird happens. When I do ifconfig, the ip address shows 192.168.50.1
But when i connect to this AP from my laptop, I cannot ping 192.168.50.1.
In fact my laptop does not get any ip in that range at all.
By doing ipconfig on my windows laptop, I found out that the laptop ip is 169.x.x.x shown as autoconfiguration IPV4 address.
When I hover my mouse over the pi taskbar wifi icon, i see it says:

wlan0: Associated with "my_home_ssid"
wlan0:configured 192.168.1.149/24
uap0:associated with testPiAP
uap0: Configured 169.254.81.27/16


Why is that? Should'nt teh uap ip address be 192.168.50.1? It seems that the dhcp ip address generation is not working.
Funny enough, when I connect to the pi Ap, I can ping the 169.254.81.27 address, and also able to ssh into it.
But I dont know why the ip assignment not working.



Thanks and regards,
Souvik.

damonh
Posts: 28
Joined: Tue Aug 15, 2017 9:31 pm

Re: Pi 3 as wiireless client and wireless AP?

Sat Mar 17, 2018 8:36 pm

I'd just like to note I was able to get client/wireless AP with bridge working today with the following white paper.

https://github.com/peebles/rpi3-wifi-st ... /README.md

It took a little doing because I had typos, but once the typos were ferreted out, I was able to get this working.
I did use an ethernet connection in order to do all the steps, but, once completed I disconnected ethernet WITHOUT a reboot and was able to connect to the AP and then VNC into the PI. I then opened a browser and was able to browse.

Though, a couple of times the connection was bumped. I was able to quickly reconnect.

My OS version:

Code: Select all

[email protected]:~ $ uname -a
Linux raspberrypi 4.9.80-v7+ #1098 SMP Fri Mar 9 19:11:42 GMT 2018 armv7l GNU/Linux
Very happy with this. Next I am going to make a PiBakery block to do this for quick setup in the future.

damonh
Posts: 28
Joined: Tue Aug 15, 2017 9:31 pm

Re: Pi 3 as wiireless client and wireless AP?

Sun Mar 18, 2018 3:28 pm

Well that was short lived.
On reboot, uap0 is no longer recognized. Thus, my AP is not working.
when trying to restart the dnsmasq here is what it reports.

Code: Select all

[email protected]:~ $ sudo journalctl -xe
-- Subject: Unit dnsmasq.service has begun start-up
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- Unit dnsmasq.service has begun starting up.
Mar 18 15:25:16 raspberrypi dnsmasq[2197]: dnsmasq: syntax check OK.
Mar 18 15:25:16 raspberrypi dnsmasq[2200]: dnsmasq: unknown interface uap0
Mar 18 15:25:16 raspberrypi dnsmasq[2200]: unknown interface uap0
Mar 18 15:25:16 raspberrypi dnsmasq[2200]: FAILED to start up
Mar 18 15:25:16 raspberrypi systemd[1]: dnsmasq.service: Control process exited, code=exited status=2
Mar 18 15:25:16 raspberrypi systemd[1]: Failed to start dnsmasq - A lightweight DHCP and caching DNS server.
-- Subject: Unit dnsmasq.service has failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- Unit dnsmasq.service has failed.
-- 
-- The result is failed.
Mar 18 15:25:16 raspberrypi systemd[1]: dnsmasq.service: Unit entered failed state.
Mar 18 15:25:16 raspberrypi sudo[2191]: pam_unix(sudo:session): session closed for user root
Mar 18 15:25:16 raspberrypi systemd[1]: dnsmasq.service: Failed with result 'exit-code'.
Mar 18 15:25:19 raspberrypi sudo[2211]:       pi : TTY=pts/0 ; PWD=/home/pi ; USER=root ; COMMAND=/bin/journalctl -xe
Mar 18 15:25:19 raspberrypi sudo[2211]: pam_unix(sudo:session): session opened for user root by (uid=0)

epoch1970
Posts: 1840
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Pi 3 as wiireless client and wireless AP?

Sun Mar 18, 2018 7:08 pm

That “white paper” you mention is out of date.
One should avoid using rc.local, and ifup/ifdown should not be used (if they work at all) with Stretch.
The end result is that uap0 is not created or created after wlan0 is configured, which fails.

AFAIK both interfaces must use the same channel, so there might be an extra step required to adapt the hostapd configuration file to match the channel the client interface has connected to...

All in all, I wouldn’t expect and demand too much from a virtual interface setup.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

projectcornholio
Posts: 5
Joined: Fri Dec 30, 2016 4:59 am

Re: Pi 3 as wiireless client and wireless AP?

Thu Apr 05, 2018 3:50 pm

So I got my Pi3 acting as a client on my home network and an AP bridge (on Jessie) using the instructions here:
viewtopic.php?f=36&t=138730&start=25#p948154

I stopped where it says "Ignore next step if wlan0 is up and working." because everything was working great.

Just to help anyone else that forgets you have to enable ssh, do yourself a favor and enable it with the raspi-config menu and you'll be able to ssh to the AP address :)

Stkenneth
Posts: 4
Joined: Tue May 29, 2018 5:14 am

Re: Pi 3 as wiireless client and wireless AP?

Tue May 29, 2018 5:49 am

Hi guys,
I'm running on stretch here
And did all the following and had 99% success

I have my client side as dhcp, I run dnsmasq on my ap side to give out ip. So far everything is working

The pi can connect to internet through wlan0, and my pc can connect and get an ip through uap0.
Here's the problem, so dnsmasq does it work by giving out ip, and my pc can receive the ip settings. But other than that nothing works. I cannot ping 192.168.42.1 (the uap0 gateway), I cannot ssh to it, and cannot and to it.

But funny thing is, if I run hostapd on wlan0 (restart the pi and DO NOT create uap0 interface), change the hostapd conf to run on wlan0 interface, it works. I can access 192.168.42.1
But once I created uap0 and tried to run hostapd on wlan0 again, it says "wlan0 wasn't started"
And I know for stretch it supposed to show that. So I have to run it on the AP interface. In the uap0 interface my pc can get ip address and connect but cannot ping/vnc/ssh the 192.168.42.1.

Thanks for all the great tutorial!
Specially @anthony19114 @surfertim!

SurferTim
Posts: 1689
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Pi 3 as wiireless client and wireless AP?

Tue May 29, 2018 11:06 am

Stkenneth wrote: Hi guys,
I'm running on stretch here
And did all the following and had 99% success

Thanks for all the great tutorial!
Specially @anthony19114 @surfertim!
Which tutorial did you follow? I've posted two. Did you do this?
Edit /etc/rc.local and add this above "exit 0". Note that is two underscores on __ap.

Code: Select all

service hostapd stop
service dnsmasq stop
iw dev wlan0 interface add uap0 type __ap
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
ifdown wlan0
ip link set uap0 up
ip addr add 192.168.4.1/24 broadcast 192.168.4.255 dev uap0
service hostapd start
ifup wlan0
service dnsmasq start

Stkenneth
Posts: 4
Joined: Tue May 29, 2018 5:14 am

Re: Pi 3 as wiireless client and wireless AP?

Tue May 29, 2018 5:21 pm

SurferTim wrote:
Tue May 29, 2018 11:06 am
Which tutorial did you follow? I've posted two. Did you do this?
well i did basically just like yours in github and a bit like how anthony anthony19114 in the first page too.

here is what i did

dhcpcd conf file :

Code: Select all

interface eth0
metric 300
static domain_name_servers=8.8.8.8
inform 192.168.88.99
static routers=192.168.1.1
noipv6

interface wlan0 #I wlan0 to be dhcp not static
metric 200
static domain_name_servers=8.8.8.8 8.8.4.4
noipv6

interface uap0
nohook wpa_supplicant
metric 250
static ip_address=192.168.42.1/24
static routers=192.168.42.1
static domain_name_servers=8.8.8.8 8.8.4.4
static domain_search=
denyinterfaces uap0
dnsmasq conf file :

Code: Select all

interface=lo,uap0
no-dhcp-interface=lo,wlan0
dhcp-range=192.168.42.50,192.168.42.150,255.255.255.0,12h
hostapd conf file :

Code: Select all

#user mod
# This is the name of the WiFi interface we configured above
interface=uap0

# Use the nl80211 driver with the brcmfmac driver
#driver=nl80211

# This is the name of the network
ssid=SSID

# Use the 2.4GHz band
hw_mode=g

# Use channel same as wlan0 channel, which is always connected in my home, which is 11
channel=11

# Enable 802.11n
ieee80211n=1

# Enable WMM
wmm_enabled=1

# Enable 40MHz channels with 20ns guard interval
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]

# Accept all MAC addresses
macaddr_acl=0

# Use WPA authentication
auth_algs=1

# Require clients to know the network name
ignore_broadcast_ssid=0

# Use WPA2
wpa=2

# Use a pre-shared key
wpa_key_mgmt=WPA-PSK

# The network passphrase
wpa_passphrase=PASSWORD

# Use AES, instead of TKIP
rsn_pairwise=CCMP

#user mod

rc.local file :

Code: Select all

/bin/bash /home/wlan0-apcli3
bash file (wlan0-apcli3) :

Code: Select all

sudo systemctl stop hostapd.service
sudo systemctl stop dnsmasq.service
sudo systemctl stop dhcpcd

sudo iw dev wlan0 interface add uap0 type __ap
sudo ip link set dev uap0 up #sudo ifup uap0
sudo ip link set uap0 address b8:27:eb:56:3c:26
sleep 5
sudo ip link set dev wlan0 down
sleep 5
sudo ip link set dev wlan0 up
sudo systemctl start dhcpcd
sleep 10
sudo service dnsmasq restart
sudo service [email protected] restart
#sudo sysctl net.ipv4.ip_forward=1
#sudo iptables -t nat -A POSTROUTING -s 192.168.42.0/24 ! -d 192.168.42.0/24 -j MASQUERADE
#sudo iptables -t nat -A  POSTROUTING -o wlan0 -j MASQUERADE
sudo hostapd /etc/hostapd/hostapd.conf

I commented out all iptables setup for now, i will only continue to iptables and stuff if i can connect my ssh/vnc or at least success to ping my pi AP interface first.

and really thankyou for replying so quick @surfertim!

Stkenneth
Posts: 4
Joined: Tue May 29, 2018 5:14 am

Re: Pi 3 as wiireless client and wireless AP?

Wed May 30, 2018 1:20 pm

I just did another try and went successful!

turns out, I am not supposed to change the uap0 mac addr, when I commented out the

Code: Select all

sudo ip link set uap0 address b8:27:eb:56:3c:26
both uap0 and wlan0 works as how they supposed to!

funny that most people said that they should have different mac address while when i gave them different, the interface that I changed will not function!

so far I have solved my problem but if someone could explain why this happened, it would be really great!

SurferTim
Posts: 1689
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Pi 3 as wiireless client and wireless AP?

Wed May 30, 2018 1:25 pm

I've never tried changing the mac address. It isn't in the access point tutorial or any of my posts.

Stkenneth
Posts: 4
Joined: Tue May 29, 2018 5:14 am

Re: Pi 3 as wiireless client and wireless AP?

Wed May 30, 2018 4:00 pm

SurferTim wrote:
Wed May 30, 2018 1:25 pm
I've never tried changing the mac address. It isn't in the access point tutorial or any of my posts.
well when i was reading through, i see some people change the mac addr to make it work so I did it just to make sure things work.

some guide that agree changing the mac :
https://superuser.com/questions/615664/ ... e-in-linux
https://albeec13.github.io/2017/09/26/r ... mode-wifi/

the first link is really the one got me into thinking of doing it even before my first try.

SurferTim
Posts: 1689
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Pi 3 as wiireless client and wireless AP?

Wed May 30, 2018 8:53 pm


Nemesis7
Posts: 1
Joined: Thu Jun 14, 2018 6:19 am

Re: Pi 3 as wiireless client and wireless AP?

Thu Jun 14, 2018 6:33 am

Stkenneth wrote:
Tue May 29, 2018 5:21 pm
SurferTim wrote:
Tue May 29, 2018 11:06 am
Which tutorial did you follow? I've posted two. Did you do this?
well i did basically just like yours in github and a bit like how anthony anthony19114 in the first page too.

here is what i did

dhcpcd conf file :

Code: Select all

interface eth0
metric 300
static domain_name_servers=8.8.8.8
inform 192.168.88.99
static routers=192.168.1.1
noipv6

interface wlan0 #I wlan0 to be dhcp not static
metric 200
static domain_name_servers=8.8.8.8 8.8.4.4
noipv6

interface uap0
nohook wpa_supplicant
metric 250
static ip_address=192.168.42.1/24
static routers=192.168.42.1
static domain_name_servers=8.8.8.8 8.8.4.4
static domain_search=
denyinterfaces uap0
dnsmasq conf file :

Code: Select all

interface=lo,uap0
no-dhcp-interface=lo,wlan0
dhcp-range=192.168.42.50,192.168.42.150,255.255.255.0,12h
hostapd conf file :

Code: Select all

#user mod
# This is the name of the WiFi interface we configured above
interface=uap0

# Use the nl80211 driver with the brcmfmac driver
#driver=nl80211

# This is the name of the network
ssid=SSID

# Use the 2.4GHz band
hw_mode=g

# Use channel same as wlan0 channel, which is always connected in my home, which is 11
channel=11

# Enable 802.11n
ieee80211n=1

# Enable WMM
wmm_enabled=1

# Enable 40MHz channels with 20ns guard interval
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]

# Accept all MAC addresses
macaddr_acl=0

# Use WPA authentication
auth_algs=1

# Require clients to know the network name
ignore_broadcast_ssid=0

# Use WPA2
wpa=2

# Use a pre-shared key
wpa_key_mgmt=WPA-PSK

# The network passphrase
wpa_passphrase=PASSWORD

# Use AES, instead of TKIP
rsn_pairwise=CCMP

#user mod

rc.local file :

Code: Select all

/bin/bash /home/wlan0-apcli3
bash file (wlan0-apcli3) :

Code: Select all

sudo systemctl stop hostapd.service
sudo systemctl stop dnsmasq.service
sudo systemctl stop dhcpcd

sudo iw dev wlan0 interface add uap0 type __ap
sudo ip link set dev uap0 up #sudo ifup uap0
sudo ip link set uap0 address b8:27:eb:56:3c:26
sleep 5
sudo ip link set dev wlan0 down
sleep 5
sudo ip link set dev wlan0 up
sudo systemctl start dhcpcd
sleep 10
sudo service dnsmasq restart
sudo service [email protected] restart
#sudo sysctl net.ipv4.ip_forward=1
#sudo iptables -t nat -A POSTROUTING -s 192.168.42.0/24 ! -d 192.168.42.0/24 -j MASQUERADE
#sudo iptables -t nat -A  POSTROUTING -o wlan0 -j MASQUERADE
sudo hostapd /etc/hostapd/hostapd.conf

I commented out all iptables setup for now, i will only continue to iptables and stuff if i can connect my ssh/vnc or at least success to ping my pi AP interface first.

and really thankyou for replying so quick @surfertim!
So I followed your (very nice) guide on setting this op on a 3B+ for a 5GHz network (both the client as the AP), incl. the commenting out the settings of the Mac address, which seems to work until the AP starts, then WiFi chip basically crashes and I get a list of errors, starting with these:

Code: Select all

brcmfmac brcmf_link_down wlc_disassoc failed (-11)
brcmfmac: brcmf_sdio_hostmail: Unknown mailbox data content: 0x40012
Issue is described here: https://github.com/raspberrypi/linux/issues/2453. What are you doing differently except for the 2.4 GHz band?

wanstreet
Posts: 38
Joined: Fri Jun 01, 2018 5:28 am

Re: Pi 3 as wiireless client and wireless AP?

Thu Jun 21, 2018 9:50 am

Bartgast wrote:
Wed Jan 24, 2018 4:19 pm
@SurferTim

Tim as well here :)

PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

So I have been trying to make it work for a week now, getting to understand more and more, but I did not get any Internet access so far. One of the problems is the dozens of guides i have been working with and losing track of it.
I am trying to achieve the exact same thing as you. However I needed to swap wlan0 and wlan1 since my wlan1 (TP-Link W722N v1.10) was not starting the AP because of driver nl80211 error.
So eventually i had the AP running on wlan0 (onboard wifi) but still no internet.
After reading somemore I noticed you post about not touching /etc/network/interfaces so i started again.

After following all these guides i never was able to access the internet. So my question is as follows; Which part allows access to the internet (i believe the IP tables but as mentioned before, it never worked for me, which can be because i was following older guides for Jessie).
Can you try hosting the wlan0 as AP and that tp-link wifi adapter as station-wifi.
Just tell dhcpcd to give IP address to the tp-link interface and not to the wlan0.
can you give this method a try or if u already have then what was the outcome?

Return to “Networking and servers”

Who is online

Users browsing this forum: No registered users and 9 guests