David Ryan
Posts: 10
Joined: Wed May 16, 2018 3:53 pm

Switch between AP and Client mode on Raspbian Stretch/Raspberry PI B+

Thu Sep 06, 2018 9:31 pm

Hello all,

I've found a few resources on this topic, but I've yet to find a solid solution.

I was able to get into AP mode using this tutorial; however, I was never able to get the supplied IP addresses to work properly. My connected devices were all getting 169.*.*.* addresses. I suspect the problem came from improper traffic forwarding/iptable rules because I recognize this address as a link local.

I also struggled a bit getting it back to client mode. I was able to do so, however the link local address problem still persists and the client I'm trying to connect to denies me.

After I get that all sorted it would be ideal if I could flip between these modes with a script similar to this answer .

For what it's worth once I get the scripting taken care of I will be using Node to handle the switching.

I appreciate the help guys. Thanks in advance.

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

Re: Switch between AP and Client mode on Raspbian Stretch/Raspberry PI B+

Sat Sep 08, 2018 11:03 am

Please peruse the official documentation to setup an AP: https://www.raspberrypi.org/documentati ... s-point.md
This page describes 2 configs: 1st part a routed AP (different network for wifi than ethernet, dhcp/dns provided by Pi), 2nd part a bridged AP (wifi and ethernet on the same network, dhcp/dns provided by router).

Once you have the AP running, switching from client "STA" mode to AP mode should be a matter of:
- starting / stopping services: hostapd (+dnsmasq) started for AP, wpa_supplicant started for STA (dhcpcd starts it for you)
- make dhcpcd understand which configuration it should use for the wifi interface. I don't know how this is done. With "profiles"?
- remove iptables rules used in AP mode when switching to STA, if any.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “Beginners”