[clug] Fixed IP or dynamic

Stephen Gibson Stephen.Gibson at anu.edu.au
Mon May 4 17:38:57 MDT 2015


For the dynamic IP address access, I use the following shell script 
(taken from the raspberry pi forums), run as a cron job every 15 
minutes, to email any IP address changes.

Steve.

#!/bin/sh

SUBJ="IP"
EMAIL="your email address"

ip1=""
ip2=""

read ip1 < ip.txt
ip2=$(wget -qO- ifconfig.me/ip)
if [ -z "$ip2" ]
then
   exit
fi

if [ "$ip1" = "$ip2" ]
then
   exit
else
   echo "$ip2" > ip.txt
   echo "$ip2" | mail -s $SUBJ $EMAIL
   exit
fi




More information about the linux mailing list