Ouvrir un compte chez FreeDNS et récupérer l'url de mise à jour du dns "Direct URL".
Ex : http://freedns.afraid.org/dynamic/update.php?XXXXXXX.
Ex : http://freedns.afraid.org/dynamic/update.php?XXXXXXX.
- Créer un script pour actualiser automatiquement FreeDNS :
#/ vi /ffp/bin/dnsactual.sh
#!/ffp/bin/shSe script permet aussi d'envoyer un mail d'alerte en cas de modification de l'adresse ip via le script send-gmail.sh
#################################################################
#
# application name: dnsactual
# other files: dnsactual.conf (keeps the last updated ip)
# dnsactual.log (register date & time of the actualization)
# Author: Ernest Danton - OdE.
# Version 1.0 - 01/29/2007
# Version 1.2 - 04/01/2012 (for DNS-323)
#################################################################
SEND_GMAIL="/ffp/bin/send-gmail.sh"
FILE_LOG="/tmp/dnsactual.log"
FILE_CONF="/tmp/dnsactuel.conf"
[ -f $FILE_CONF ] && CacheIP=$(cat $FILE_CONF)
echo $CacheIP
CurreIP=$(wget -O - http://freedns.afraid.org/dynamic/check.php | grep Detected | cut -d : -f 2 | cut -d '<' -f 1 | tr -d " ")
echo $CurreIP
if [ "$CurreIP" = "$CacheIP" ]
then
# Both IP are equal
echo "Update not required..."
else
# The IP has change
echo "Updating http://free.afraid.org with " $CurreIP
# MAJ des DNS
wget -O - http://freedns.afraid.org/dynamic/update.php?XXXXXXX
[ $? -ne 0 ] && echo "ERROR Updating DNS" >> $FILE_LOG || echo `date` "Updating log with IP " $CurreIP >> $FILE_LOG
# Send Mail when IP is update via gmail
[ -f $SEND_MAIL ] && $SEND_GMAIL -s "External IP Update..." "My new external IP is : $CurreIP. It's send to dns"
fi
rm -f $FILE_CONF
echo $CurreIP > $FILE_CONF
- Créer un script pour lancer automatiquement toute les heures le script dnsactual.sh
#/ vi /ffp/start/freedns.sh
#!/ffp/bin/sh
CRONTXT=`mktemp -t tmp_cron.XXXXXXXXXXXXX`
CMD_DNSACTUAL=/ffp/bin/dnsactual.sh
# start with existing crontab
/bin/crontab -l > $CRONTXT
# add cron jobs every hour
/bin/echo "0 * * * * $CMD_DNSACTUAL" >> $CRONTXT
# install the new crontab
/bin/crontab $CRONTXT
# clean up
/bin/rm $CRONTXT
Comments
Post a Comment