par maroux » 19 Déc 2002 14:32
Bonjour à tous,
<BR>
<BR>Comme vous le savez tous, la mise automatique de dyndns sous smoothwall ne fonctionne pratiquement jamais corectement.
<BR>après quelques investigations j'ai trouvé ce script qui permettrait de mettre à jour beaucoup plus efficacement dyndns de la smoothwall box.
<BR>
<BR>le script et les explications sont disponibles sur le site suivant dan la langue de shakespeare :
<BR><!-- BBCode auto-link start --><a href="http://smoothkoops.sourceforge.net/" target="_blank">http://smoothkoops.sourceforge.net/</a><!-- BBCode auto-link end -->
<BR>
<BR>Personellement je testerais cela ce week-end.
<BR>
<BR>Voici les modifs à faire :
<BR>
<BR>This simple script checks the current IP address on your dynamic dns service via an nslookup and then compares this to your IP address currently assigned to your internet facing interface.
<BR>
<BR>If it is different then it just runs an update in the same way that a normal smoothwall box does.
<BR>
<BR>Cut and paste the script below into a file. I have put mine in "/usr/local/bin/dyndns_check.pl"
<BR>#!/usr/bin/perl
<BR>
<BR>#Get Ipaddress bound to the REAL internet adapter.
<BR>
<BR>#Change the following variable as appropriate! Use "ifconfig -a" to see all interfaces or use the web interface
<BR>
<BR>$interface="ppp0";
<BR>$dyndns_name="changethis.dyndns.org";
<BR>
<BR>
<BR>#Get the current real internet IP address.
<BR>open(IP, "/sbin/ifconfig $interface|");
<BR> $null=<IP>;
<BR> $ip=<IP>;
<BR>close (IP);
<BR>@temp=split(/:/,$ip);
<BR>@dyndns=split(/ /,@temp[1]);
<BR>$current_ip=@dyndns[0];
<BR>print "----------------------------n";
<BR>print "current_ip ...$current_ip...n";
<BR>
<BR>#Get the dyndns entry and see that it matches.
<BR>
<BR>open(NAME, "nslookup $dyndns_name|");
<BR> $null=<NAME>;
<BR> $null=<NAME>;
<BR> $null=<NAME>;
<BR> $null=<NAME>;
<BR> if ($null=~/Non-authoritative/) {
<BR> $null=<NAME>;
<BR> }
<BR> $current_name=<NAME>;
<BR>close (NAME);
<BR>$current_name=~s/ //;
<BR>$current_name=~s/n//;
<BR>$current_name=~s/,//g;
<BR>@current_name=split(/ /,$current_name);
<BR>$current_dns_ip=@current_name[1];
<BR>$current_dns_ip=~s/n//;
<BR>print "Current_dns ...$current_dns_ip...n";
<BR>
<BR>#Check that they are the same
<BR>if ($current_dns_ip eq $current_ip) {
<BR> print "IP addresses match.n";
<BR> system('date');
<BR> }
<BR>else {
<BR> print "They are different run an update!n";
<BR> system('date');
<BR> system('/usr/local/bin/setddns.pl', '-f');
<BR>}
<BR>
<BR>
<BR>
<BR>You will need to edit and change two variables in the script.
<BR>
<BR>1. "Interface" - This is the internet facing interface on your smoothwall box. With dial up or PPPoE it will usually be "ppp0".
<BR>Use the command "ifconfig -a" to find which one it is or use the web interface under the "Info" page.
<BR>2. "Dyndns_name" - This is the dyndns name that you are using eg. hotdog.dyndns.org etc etc
<BR>You will need to make this file executable. Do this by issuing the command "chmod a+x dyndns_check.pl" (or what ever you called the file!)
<BR>
<BR>Run it and make sure it it working ok. eg. "/usr/local/bin/dyndns_check.pl" see what it outputs and confirm that it is working correctly.
<BR>
<BR>
<BR>All you need to do now is add it to your crontab.
<BR>Edit the crontab and put in the following line. Change it to suit. This runs it at the start of every hour.
<BR>
<BR>0 * * * * cd /usr/local/bin && ./dyndns_check.pl >> /var/log/dyndns.log
<BR>You can either point the output to a file ie. /var/log/dyndns.log or to the null device /dev/null.
<BR>I suggest using a log file to make sure that it is working or then change it to /dev/null later.
<BR>
<BR>Bon courage à tous ceux qui experimenteront.
<BR>
<BR> <IMG SRC="images/smiles/icon_up.gif">
Lorsque viendra le peak-oil, nous devrons être beaucoup plus rigoureux dans nos utilisations de la technologie car l'énergie viendra à manquer en cas de gaspillage ...