My work laptop is used in a “road warrior” setup. This means it’s often used in whatever WLAN and other networks I find, but I have a VPN connection to the office I can use.
The company’s mailserver accepts incoming mail over the VPN and relays it for me, but I cannot just use it as smarthost on my laptop: when I sent an eMail in offline mode, as soon as any network connection comes up, Postfix runs the queue, and (unless the public network blocks port 25) the smarthost rejects it with a 5xx code because the mail arrives from an external nōn-VPN IP.
Therefore I’m looking for a solution that puts Postfix in queue-only mode unless the VPN is up. (This can easily be detected by testing whether tun13
is up, for example. The exact method to use would, of course, rely on whatever Postfix can do to check.)
Bonus: unless the VPN is up or I’m connected to company LAN (eth0) or WLAN. But that’s not urgent.
I’m using shell wrapper scripts around ifupdown to connect, so adding extra commands there is not a hardship. Simply stopping Postfix when not connected to the VPN is, however, not a solution: package upgrades and reboots tend to start it, and sending mail to [::1]:25
must work (queue-only) when the VPN is not up.
This is Debian bullseye, and OpenVPN is used (manually started/stopped from the command line), in case that matters.