Check connection

Simple script to check connection to a host, that in case of failure asks for new IP address through DHCP.

Add entry to crond of account with privileges to get address through dhclient:

   1 #!/bin/sh
   2 PROG=checkConnection
   3 HOST=dns.sedimap.pvt
   4 ping $HOST -c 5 > /dev/null 
   5 RES=$?
   6 if [ $RES -eq 0 ]; then
   7   logger "$PROG: Ping to $HOST OK"
   8 else
   9   logger "$PROG: Ping to $HOST NOK, running dhclient eth0"
  10   dhclient eth0 -v
  11   # other seervices that may need restarting
  12 fi

On Slackware the logger output should apper on /var/log/messages.

CheckConnection (last edited 2013-06-27 08:44:04 by bl14-188-151)