Mailinglist Archive: opensuse-es (2353 mails)
| < Previous | Next > |
Re: [opensuse-es] Como pruebo mi Servidor con DNS Dinamico y Cuenta no-ip O-SuSE 10.3?
- From: "Josep M. Queralt" <jmqueralt@xxxxxxxxx>
- Date: Wed, 31 Oct 2007 17:55:59 +0100
- Message-id: <20071031175556.D112.JMQUERALT@xxxxxxxxx>
El 31/10/2007 14:57:20 Carlos E. R. escribió:
robin.listas> ¡Caray! Sí que es feo. Y además, se necesita password - por lo
menos con
robin.listas> el mío. Y usa javascript, no funciona (ya probé el lynx y otros).
robin.listas>
robin.listas> Tendría que ser por telnet o ssh.
No, se hace en local. Al lynks se le pueden pasar los parámetros
incluidos el usuario y el password.
He estado buscando el script que lo hace con el Lynks pero no lo
encuentro, se que es un script en bash.
Con PHP si. No lo pongo entero, pero verás que el concepto es el mismo.
$stat_file = 'remote_ip'; # Name of the status file (apache must have
write permissions in the directory)
$log_file = 'dynamic_ip.log'; # log the history to this file
$DSL_Username = ''; # ADSL Router Username
$DSL_Password = ''; # ADSL Router Password
$DSL_Address = 'http://192.168.0.1/cgi/router/'; #U RL on the router that
displays the remote IP
$IP_Update_URL[] = 'http://freedns.afraid.org/dynamic/update.php?QUERY_STRING';
# URL to open for updating the IP
$debug = 'ON';
#Se flitra:
if(ereg('(http:\/\/)(.*)',$DSL_Address,$DSL_regs)){
if(!$DSL_Username && !$DSL_Password){
$DSL_url = $DSL_regs[1] . $DSL_regs[2]; # If there is no
Username and Password
}else{
$DSL_url = $DSL_regs[1] . $DSL_Username . ":" . $DSL_Password . "@" .
$DSL_regs[2]; # if there is a Username and Password
}
$DSL_Status = implode('',file($DSL_url));
$DSL_Status = strip_tags($DSL_Status, '');
$ipok = 0;
if(ereg('([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})',$DSL_Status,$IP_regs)){
for($i=1; $i < 5; $i++){
$ip_segment[$i] = intval($IP_regs[$i]);
if($ip_segment[$i] <= 255) $ipok++;
}
$ip = implode(".", $ip_segment);
}
}
#Mira si la IP nueva es la misma que había:
$lastIP_Status = implode('',file($stat_file));
if(ereg('([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})',$lastIP_Status,$lastIP_regs)){
if($debug='ON'){echo "Last IP was : " . $lastIP_regs[0] . "<br>\n\r";}
$last_IP = $lastIP_regs[0];
}
if($ip == $last_IP){
if($debug='ON'){echo "No change to IP : " . $ip ."<br>\n\r";}
}else{
# Create or Alter the status file.
if($debug='ON'){echo "Changing IP from : " . $last_IP . " to : " . $ip .
"<br>\n\r";}
$fname = $stat_file;
$fp = fopen($fname,'w+');
$log_ip = $ip . " Date: " . date("F j, Y, g:i a") . "\n\r";
fwrite($fp,$log_ip);
fclose($fp);
$fname = $log_file;
$fp = fopen($fname,'a');
while(list($key, $val) = each($IP_Update_URL)){
$dynamic_update = implode('',file($val));
# Create and or write to the log file.
$log_ip = "Date: " . date("F j, Y, g:i a") . " - Response :" .
$dynamic_update . "\n\r";
if($debug='ON'){echo $dynamic_update . "<br>\n\r";}
}
fwrite($fp,$log_ip);
fclose($fp);
}
?>
Comop ves no es muy complicado.
--
Saludos,
Josep M. Queralt
http://www.queralt.org/
robin.listas> ¡Caray! Sí que es feo. Y además, se necesita password - por lo
menos con
robin.listas> el mío. Y usa javascript, no funciona (ya probé el lynx y otros).
robin.listas>
robin.listas> Tendría que ser por telnet o ssh.
No, se hace en local. Al lynks se le pueden pasar los parámetros
incluidos el usuario y el password.
He estado buscando el script que lo hace con el Lynks pero no lo
encuentro, se que es un script en bash.
Con PHP si. No lo pongo entero, pero verás que el concepto es el mismo.
$stat_file = 'remote_ip'; # Name of the status file (apache must have
write permissions in the directory)
$log_file = 'dynamic_ip.log'; # log the history to this file
$DSL_Username = ''; # ADSL Router Username
$DSL_Password = ''; # ADSL Router Password
$DSL_Address = 'http://192.168.0.1/cgi/router/'; #U RL on the router that
displays the remote IP
$IP_Update_URL[] = 'http://freedns.afraid.org/dynamic/update.php?QUERY_STRING';
# URL to open for updating the IP
$debug = 'ON';
#Se flitra:
if(ereg('(http:\/\/)(.*)',$DSL_Address,$DSL_regs)){
if(!$DSL_Username && !$DSL_Password){
$DSL_url = $DSL_regs[1] . $DSL_regs[2]; # If there is no
Username and Password
}else{
$DSL_url = $DSL_regs[1] . $DSL_Username . ":" . $DSL_Password . "@" .
$DSL_regs[2]; # if there is a Username and Password
}
$DSL_Status = implode('',file($DSL_url));
$DSL_Status = strip_tags($DSL_Status, '');
$ipok = 0;
if(ereg('([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})',$DSL_Status,$IP_regs)){
for($i=1; $i < 5; $i++){
$ip_segment[$i] = intval($IP_regs[$i]);
if($ip_segment[$i] <= 255) $ipok++;
}
$ip = implode(".", $ip_segment);
}
}
#Mira si la IP nueva es la misma que había:
$lastIP_Status = implode('',file($stat_file));
if(ereg('([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})',$lastIP_Status,$lastIP_regs)){
if($debug='ON'){echo "Last IP was : " . $lastIP_regs[0] . "<br>\n\r";}
$last_IP = $lastIP_regs[0];
}
if($ip == $last_IP){
if($debug='ON'){echo "No change to IP : " . $ip ."<br>\n\r";}
}else{
# Create or Alter the status file.
if($debug='ON'){echo "Changing IP from : " . $last_IP . " to : " . $ip .
"<br>\n\r";}
$fname = $stat_file;
$fp = fopen($fname,'w+');
$log_ip = $ip . " Date: " . date("F j, Y, g:i a") . "\n\r";
fwrite($fp,$log_ip);
fclose($fp);
$fname = $log_file;
$fp = fopen($fname,'a');
while(list($key, $val) = each($IP_Update_URL)){
$dynamic_update = implode('',file($val));
# Create and or write to the log file.
$log_ip = "Date: " . date("F j, Y, g:i a") . " - Response :" .
$dynamic_update . "\n\r";
if($debug='ON'){echo $dynamic_update . "<br>\n\r";}
}
fwrite($fp,$log_ip);
fclose($fp);
}
?>
Comop ves no es muy complicado.
--
Saludos,
Josep M. Queralt
http://www.queralt.org/
| < Previous | Next > |