When the device is in the office, you could run a simple shell script that adapts it's network setting to the office situation.
Another possibility is to run a cron job every minute or so. When the device fails to connect to the external IP, adjust the network settings.
On my OpenBSD desktop, I use the following script in cron to start the
ntpd daemon when I have network access, and just forget about it when there isn't .
Code:
#!/bin/sh
# ---- to be used in root's crontab for machines not always connected
GATEWAY=192.168.222.10
date
if pgrep ntpd >/dev/null 2>&1 ; then
echo ntpd already running
exit 0
fi
if ping -c3 $GATEWAY >&2 ; then
# connection to gateway exists
echo Starting ntpd ....
ntpd -s
exit 0
else
echo "Gateway not alive, cannot run ntpd"
exit 1
fi