Ive got a PI set up where I want to switch between acting as an AP and acting like a normal user of a wifi network.
Currently I have to reboot to make this work, but i'm certain there's just a tiny piece of the puzzle I'm overlooking.
In AP mode all traffic is resolved to the internal web browser, and I think its this that gets stuck somewhere.
My current process is:
# switch to AP mode
cp interfaces.fixed /etc/network/interfaces
systemctl enable hostapd.service
systemctl enable dnsmasq.service
systemctl enable bluetooth
systemctl disable wpa_supplicant.service
systemctl reboot
and
# switch to client mode
cp interfaces.dhcp /etc/network/interfaces
systemctl disable hostapd.service
systemctl disable dnsmasq.service
systemctl disable bluetooth
systemctl enable wpa_supplicant.service
systemctl reboot
Logically I think i should be able to swap the [dis|en]able for st[op|art], but if I do this then the Pi gets an IP address, but no traffic escapes.
What am I missing?
start
orenable --now
. I also wrote something to do this automatically, it works with stretch and buster. You may want to have a look at it and adopt it to your needs. – jake Sep 15 '19 at 22:32enable
is to cause a service to start on boot. You need tostop
services beforestart
ing incompatible services. If using Raspbian (which usesdhcpcd
to manage networks) this needs to be stopped (or prevented from configuring WiFi interfaces) – Milliways Sep 16 '19 at 00:09systemctl restart systemd-networkd
after an update tointerfaces
file if you don't want to reboot, and start services instead of just enabling. See what @jake did in Automatically Create Hotspot if no Network is Available - it looks like it covers your needs. – Dmitry Grigoryev Sep 16 '19 at 07:21