[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: vsftpd, ip dynamique, routeur et mode passif



Jean-Michel OLTRA a écrit :

	bonjour,




Donne le format des fichiers old_ip et new_ip

Je vais essayer de faire un petit script python (car python c'est bon)
mais j'aimerais savoir quoi lire dans ces fichiers ci. Mais je crains
d'être obligé de passer par une commande externe pour récupérer le pid
de vstpd, manière de lui lancer un kill -HUP

Je suis sûr qu'en ce beau vendredi où le troll bourgeonne duf va cracher
un peu de code...

Salut,
voilà le script complet qui me permet d'updater mon ip vers dyndns via ez-ipupdate :


Here's a noob friendly How-To for setting up ez-ipupdate on a networked machine behind a cable/dsl router (where the router is the actual device where the IP changes).

This document assumes you have ez-ipupdate already installed and ready to go, with a config file of /etc/ez-ipupdate.conf. The scripts used in this How-To are based on scripts submited by philliptemple and REM_simone, also in this thread. The scipts have been modified to be more resource friendly and to only call ez-ipupdate when your IP actually changes.

Create a file called dns_update in /usr/local/bin with the following content:

#!/bin/bash

wget --quiet -O - http://checkip.dyndns.org | awk '{print $6}' | sed -e 's/<\/body><\/html>.*//' > /tmp/new_ip

if [ -n "`cat /tmp/new_ip`" ]
then
  if [ -n "`diff --brief /tmp/old_ip /tmp/new_ip`" ]
  then
    ez-ipupdate --address `cat /tmp/new_ip` -c /etc/ez-ipupdate.conf
  fi
fi

cp -f /tmp/new_ip /tmp/old_ip
# end of file

Then make sure the script is executable with this command:

chmod 755 dns_update

This script uses a web page at dyndns.org to get your current IP and saves the results to file. If the file is not empty and the IP doesn't match what it was the last time the script was run, ez-ipupdate is executed.

Before running this script the first time, you should create an empty 'old_ip' file in /tmp so an error is not reported.
You can do that with the following command:

cat /dev/null > /tmp/old_ip


To get this script to run every ten minutes, execute the following command to set up a cron job:

crontab -e

Then enter the following line and save the file (:x)

0-59/10 * * * * /usr/local/bin/dns_update


C'est un peu long, désolé, mais je voulais être sûr de ne rien oublier.
Merci de votre aide !

--
Pour me répondre, prière d'ôter le "Spam-poum." de mon adresse.



Reply to: