Only run on specific Wifi networks

Hi together,

I’d like to run the syncthing linux service (my machine is running systemd) only when a specific wifi (or list of wifis) is connected. Has someone done this before?

My motivation is to increase security (reduce attack surface) by not running a service with open ports on untrusted networks.

What I found so far:

  1. I want the same behavior as on Android (SettingsRun ConditionsRun on specified Wi-Fi networks), but on Linux.
  2. On linux, the config option `allowedNetworks` is nice to limit traffic to local networks only. However, it does not allow me to limit to a specific network.
  3. Another user has a similar problem: pause on metered wifi on linux

Some more information:

  • My system is using systemd and NetworkManager
  • syncthing is running as user context, not system context

There is no such functionality inside Syncthing itself. How about using a firewall to block Internet access for the Syncthing binary?