View previous topic :: View next topic |
Author |
Message |
assassin n00b
Joined: 12 Nov 2003 Posts: 71
|
Posted: Tue Apr 13, 2004 1:38 pm Post subject: Modem IP aktualisieren |
|
|
Hallo zusammen,
ich habe meinen Server an einem ADSL Modem dran.
Nun wenn dieses Modem eine neue IP erhält, muss dies der server merken
und nachtragen. Ich habe schon davon gehört, dass man ein
Script laufen lassen kann, hat jemand einen Link, ein Howto oder ein
beispiel ??
peaspeas Thomas _________________ My name is Guybrush Threepwood and I want to be a pirate!! |
|
Back to top |
|
|
dakjo Veteran
Joined: 31 Jan 2004 Posts: 1544
|
Posted: Tue Apr 13, 2004 2:57 pm Post subject: |
|
|
Du könntest tracerout nehmen um es vom server festzustellen, oder du baust es in ip-up ein, das du den Server jedesmal benachrichtigst, wenn sich die adresse ändert. |
|
Back to top |
|
|
ruth Retired Dev
Joined: 07 Sep 2003 Posts: 640 Location: M / AN / BY / GER
|
Posted: Tue Apr 13, 2004 3:00 pm Post subject: |
|
|
hi,
aalso:
ich hab weder ein howto, noch irgendeinen plan aber das da:
Code: |
#!/usr/bin/perl
#
# (c) 2003 by rootshell <rootshell@front.ru>
#
#
# version 0.2 release 31/08/2003
#
#
# If you have any comments, suggestions, etc., feel free to send me a mail ;-))
# flames and other things like that will go to /dev/null
#
#
# This script is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this software; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Installation Howto:
# download IO::LockedFile from http://www.cpan.org/modules/by-modu...ile-0.23.tar.gz
# download Log::LogLite from http://www.cpan.org/modules/by-modu...ite-0.82.tar.gz
# and install.
# install script as /etc/ppp/ip-up or for example as /usr/bin/webupdate.pl ( daemon-mode )
# set $daemon to "0" when run as /etc/ppp/ip-up
# if running as daemon execute: /usr/bin/webupdate.pl &
# to fork process into background
#
use Net::FTP;
use Log::LogLite;
## user configurable values...
$ftp_hostname = "some.host.com"; # welcher ftp ???
$ftp_username = "anonymous"; # username
$ftp_password = "geheim"; # !!! CLEARTEXT !!!
$ftp_directory = "/htdocs"; # in welches verzeichniss wechseln??
$ftp_filename = "index.html"; # name der angelegten datei
#
$daemon = "1"; # set to 0, if running as /etc/ppp/ip-up
# the following settings are for daemon mode only
$interval = "60"; # default_check_interval; integer in secs.
$interface = "ppp0"; # interface to be checked for ip changes...
$ifconfig = "/sbin/ifconfig";
##### end of user configuration...
my $LOG_DIRECTORY = "/var/log";
my $ERROR_LOG_LEVEL = 6;
my $log = new Log::LogLite($LOG_DIRECTORY."/webupdate.log", $ERROR_LOG_LEVEL);
$log->write("webupdate.pl is starting up... ", 4);
$log->write("(c) 2003 by rootshell", 4);
### subroutines ###
sub do_interface_check {
$status = system ("$ifconfig $interface 1>/dev/null 1>/dev/null");
sleep 3;
do_interface_check() unless $status == 0;
return;
}
sub get_current_ip {
do_interface_check();
open(RAW_IP,"$ifconfig $interface | grep inet |");
@raw_ip = <RAW_IP>;
foreach $raw_ip (@raw_ip) {
($c, $s, $address) = split (/[.:,;?!]*\s+/, $raw_ip);
($a, $ip_address) = split (/:/, $address);
}
close(RAW_IP) or die "'unable to execute...\n";
return ($ip_address);
}
sub update_website {
@newsite = ("<html>\n",
"<head>\n",
"<title> Automatische Umleitung zu meinem dsl-rechner ;-) </title>\n",
"<script language=JavaScript>\n",
"window.open ('$ip_address', '_parent');\n",
"</script>\n",
"</head>\n",
"<body>\n",
"</body>\n",
"</html>\n");
open (NEWSITE, ">newsite");
print NEWSITE @newsite;
close (NEWSITE);
$ftp = Net::FTP->new("$ftp_hostname", Debug => 0)
or die "Cannot connect to $ftp_hostname: $@";
$ftp->login("$ftp_username","$ftp_password")
or die "Cannot login ", $ftp->message;
$ftp->cwd("$ftp_directory")
or die "Cannot change working directory ", $ftp->message;
$ftp->ascii();
$ftp->put("newsite", "$ftp_filename")
or die "put failed ", $ftp->message;
$ftp->quit;
if (open(FILE, "< newsite")) {
close (FILE);
system ("rm newsite")
}
$log->write("finished update... ", 4);
return;
}
### end subroutines ###
$ip_old = "";
if ( $daemon == 1 ) {
$log->write("will check ip-address every $interval seconds... ", 4);
while (1) {
sleep $interval;
get_current_ip();
if ( $ip_address eq $ip_old ) {
$log->write("IP-Address NOT changed, no update... ", 4);
}
else {
$log->write("IP-Address changed, will update now... ", 4);
update_website($ip_address);
$ip_old = $ip_address;
}
}
} else {
$ip_address = $ARGV[2];
$log->write("pppd called me ;-) -> will update now... ", 4);
update_website($ip_address);
}
exit;
|
ist zwar nicht wirklich, was du suchst, aber du kannst es toll anpassen + verarbeiten...
denke, mit ca. 15 min. arbeit bist du am ziel...
wieder mal aus meinem riiesigen sciptarchiv...
lg
rootshell _________________ "The compiler has tried twice to abort and cannot do so; therefore, compilation will now terminate."
-- IBM PL/I (F) error manual |
|
Back to top |
|
|
dakjo Veteran
Joined: 31 Jan 2004 Posts: 1544
|
Posted: Tue Apr 13, 2004 5:13 pm Post subject: |
|
|
rootshell, findet man dein scriptarchiv online ? |
|
Back to top |
|
|
ruth Retired Dev
Joined: 07 Sep 2003 Posts: 640 Location: M / AN / BY / GER
|
Posted: Wed Apr 14, 2004 6:32 pm Post subject: |
|
|
hi,
nein, bis jetzt nicht...
die dinger liegen im augenblick wild verteilt auf meiner platte, div. cds, foren + cvs'en rum...
muss mal ordnen die dinger...
decken jedenfalls ein ziemlich grosses spektrum ab...
muss mal schauen, wann ich dazukomm..
ach ja:
eines davon ist zum beispiel hier:
http://www1.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/TOOLS/dvd2divxscript.pl
andere in diversen foren verteilt (auch hier...)
wieder andere release ich mit sicherheit nicht...
ich liiebe perl...
gruss
rootshell _________________ "The compiler has tried twice to abort and cannot do so; therefore, compilation will now terminate."
-- IBM PL/I (F) error manual |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|