I’m currently working on a portable headless project with a Raspberry Pi Zero W, on which I have installed Arch Linux, and am currently using systemd-networkd to connect it wirelessly to my home router. I want to be able to have it auto-connect to a prioritised pair of SSIDs using different static IPs for each SSID, for the following use case:
When I’m using it away from home, I need it to automatically connect to my Android device’s wireless hotspot using a static IP (so that I can easily SSH or VNC into it from my phone).
When I’m at home I also need to be able to SSH into it from my home LAN to perform administration, again using a static IP for ease of SSH access.
However, when I’m at home I also need to be able to connect it to my phone for testing purposes and to have it automatically switch between SSIDs based on the presence or absence of my Android hotspot.
To add to the complications, my home router uses a different IP range from my Android phone, so the static IP will need to be different on both connections.
Ideally, I need the Pi to work as follows:
- If it detects my Android Hotspot’s SSID, it will connect to that exclusively, using a static IP address specific to that SSID
- If it doesn’t detect my Android Hotspot’s SSID it will instead attempt to connect to my home Wifi SSID using a different static IP
This means that I can test the Pi at home using my phone simply by switching on my phone’s hotspot, and I can administer it using my home PC by switching the hotspot off.
Does anyone know how I can achieve this?