WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Pi Zero2W as both WiFi client and Access Point  (Read 2095 times)

Offline obutk

  • Newbie
  • *
  • Posts: 8
Pi Zero2W as both WiFi client and Access Point
« on: March 17, 2022, 11:16:56 PM »
I have been trying, without success, to configure the Raspberry Pi Zero 2 W as both wifi client and access point (simultaneously) with piCore 13.1.

I have tried a few different tutorials, like this one posted by gpulido: http://forum.tinycorelinux.net/index.php/topic,16181.msg95878.html#msg95878, however there is always something different that does not go as expected.

Has anyone done this with piCore? Could you please share how you did it?
Bridging the access point to the wifi network (working as a hotspot) would also be nice, but it is not a requirement for me.

« Last Edit: March 17, 2022, 11:21:03 PM by obutk »

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11041
Re: Pi Zero2W as both WiFi client and Access Point
« Reply #1 on: March 18, 2022, 03:46:52 AM »
Are you sure that's even possible? Many wifi devices don't support simultaneously using two modes. Or do you have two wifi devices?
The only barriers that can stop you are the ones you create yourself.

Offline obutk

  • Newbie
  • *
  • Posts: 8
Re: Pi Zero2W as both WiFi client and Access Point
« Reply #2 on: March 18, 2022, 07:13:32 AM »
Are you sure that's even possible? Many wifi devices don't support simultaneously using two modes. Or do you have two wifi devices?

I was able to do it a couple months ago by following this tutorial (in portuguese) for the "raspberry os": https://www.filipeflop.com/blog/configure-raspberry-pi-como-access-point/

It uses only the onboard hardware of the raspberry, without any additional device.

Offline obutk

  • Newbie
  • *
  • Posts: 8
Re: Pi Zero2W as both WiFi client and Access Point
« Reply #3 on: April 30, 2022, 04:42:36 PM »
It's been a while. I don't remember the steps exactly, but I think I've managed to do it.

I had to create an "ap0" network interface by creating the 70-persistent-net.rules file (the process is described in the previous link I've sent). wlan0 is used to access wifi, and ap0 will be used to provide an access point. When the ap0 interface is created, the wlan0 is deactivated, so at some point I had to call "ifconfig wlan0 up" or something similar. I've heard that the order in which the interfaces are turned up matters, so you might have to try turning the ap0 on before (or after) the wlan0. At this point I think you should be able to see both interfaces when you use the command ifconfig.

Then I had to tweak the wifi.sh script because it was trying to use the ap0 interface to connect to wifi. I hardcoded it to use the wlan0.

Now that both ap0 and wlan0 interfaces exist, I followed the tutorials at RPI official docs:

https://www.raspberrypi.com/documentation/computers/configuration.html#setting-up-a-routed-wireless-access-point

Just keep in mind that tc uses a different path for the hostapd and dhcpcd configuration files: /usr/local/etc (if I'm not mistaken). Because I don't want any kind of bridging, I skipped the section "Enable Routing and IP Masquerading".

After a few more tweaks (which I unfortunately don't remember right now), I finally got both access point and wifi working at the same time. The channel used by the access point must be the same channel used by the wifi, so first you have to check the channel that your wifi network is using and then configure the hostapd file accordingly.


« Last Edit: April 30, 2022, 05:09:51 PM by obutk »