View Single Post
  #2   (View Single Post)  
Old 9th July 2009
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,125
Default

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
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote