Recherche :

ScriptsUnixPourIpDynamique

Accueil :: DerniersChangements :: DerniersCommentaires :: ParametresUtilisateur :: Vous êtes 38.103.63.18

Derrière un proxy


Voici un petit script unix qui fait l'affaire: il récupère l'ip via le script getip, et met à jour l'IP si besoin.



#!/bin/bash
export old_ip=`cat /tmp/my_ip`
export ip=`curl -s http://rrdata.free.fr/getip.php`
if [ "$old_ip" != "$ip" ] ; then
echo "changing ip"
echo "$ip" >/tmp/my_ip
curl http://www.apinc.org/board/dns/dyn.php?id=XXXXXXXX\&ip=$ip
fi



le script getip.php est tout simplement:


<?php
echo getenv("REMOTE_ADDR");
?>


Dans la crontab, on fait le test toutes les demi-heures:


0,30 * * * * /path/to/updatescript.sh



Il n'y a pas de commentaire sur cette page. [Afficher commentaires/formulaire]