Much like my PHP example of external IP reporting, the following script performs exactly the same task, but in Centos. This combined with creating a custom system service should provide dynamic IP resolution even if the PC reboots.
while [ $i == 1 ]
datestring=$(date –utc +%FT%TZ)
echo “Getting IP… ”
wanip=$(dig +short EXTERNAL IP RESOLVER ADDRESS)
#if [ 1 -ne 1 ]
if [ $oldip != $wanip ]
echo My IP has changed! Saving change to file…
echo $wanip > $ipdir$ipfile
echo Connecting to FTP server…
lftp -u FTP_USERNAME,FTP_PASSWORD FTP_SITE -e ” lcd $ipdir; put $i$
echo Writing log…
echo “$datestring IP changed to $wanip” >> $logfile
echo Log written!
echo My IP is the same!
echo Sleeping for 5 mins…