0

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?

Will8
  • 1

1 Answers1

1

You do not tell us why you want to have it complex. That would be interesting. You can have both connections at the same time so normally there is not need to switch anything. But if you want to do it you can use systemd-networkd. With it you can make clean services for each task, one service for the access point and one service for the client connection. Using dependencies you can just start the service you want, no need to stop the other. That is done automatically.

How to manage this you can look at Switch between wifi client and access point without reboot.

Ingo
  • 42,961
  • 20
  • 87
  • 207