ipcheck.pl

das ganze als cronjob verewigen 0-59/6 ....

# 
# This script connects to a website for determining the router's current IP 
# 
# Written 2003 Markus Rechberger <markus@shell.dnload.com> 
# 
 
use LWP::Simple; 
use URI::URL; 
use HTTP::Request; 
use LWP::UserAgent; 
 
print"Determining the routers external IP address...\n"; 
$ua=LWP::UserAgent->new; 
$ua->agent("Interface Explorer 1.0 :)"); 
$ua->proxy(['http'],'http://proxy.telenet.be:8080/'); 
$req234 = HTTP::Request->new('GET'=>"http://nexflo.net/clients/securityxml/info.php"); 
$contentx=$ua->request($req234)->as_string; 
$remip=substr($contentx,index($contentx,"REMOTEIP:")+9,index($contentx,"br")-index($contentx,"REMOTEIP:")-10); 
$tempy=substr($contentx,index($contentx,"XREMOTEIP:")+10); 
$xremip=substr($contentx,index($contentx,"XREMOTEIP:")+10,index($tempy,"<")); 
print"Fetched IP address $xremip\n"; 
print"Comparing fetched IP with current IP\n"; 
$current=`cat /etc/current`; 
if($current eq $xremip){ 
        print"..... current IP is up to date\n"; 
} else { 
        print"Renewing secxml.homelinux.net\n"; 
        $exec=`rm ipcheck.dat; ipcheck.py --makedat -a $xremip login passwort xxxxxx.homelinux.net`; 
        open(FILE,">/etc/current"); 
        print FILE "$xremip"; 
        close(FILE); 
} 
open(FILE,">/ipcheck/log"); 
$date=`date`; 
print FILE "last check was on $date\n"; 
close(FILE); 
print"done... have a nice day\n"; 

MarkusRechberger/ipcheck.pl (zuletzt geändert am 2007-12-23 22:45:40 durch localhost)