Hello everyone,
Listed below a little perl script witch automaticaly mail the public IP of a PPP connection managed by the firewall. It's very usefull if u don't have a static public IP or a dynamic DNS ...
after only add a line in the crontab like this :
0 * * * * root /bin/perl /bin/mail_ip.pl
>>>>>>>>> Snip Snip : /bin/mail_ip.pl " ;="" my="" $mail_srv="" ;="" my="" @mail_det="qw" (="" adress_mail_user_1="" adress_mail_user_2="" ...="" )="" ;="" #="" #="" get="" actual="" ip="" #="" my="" $cmd="ifconfig ppp0 | grep inet | awk '{print \$2}' | sed 's/^addr://g'" ;="" my="" @tmp="`$cmd`" ;="" foreach="" (="" @tmp="" )="" {="" chomp="" ;="" s/^\s//;="" s/\s+$//;="" }="" my="" $addr="@tmp[0]" ;="" #="" #="" get="" last="" ip="" found="" during="" last="" execution="" of="" this="" script="" #="" $cmd="cat /tmp/wan_addr_flag" ;="" @tmp="`$cmd`" ;="" foreach="" (="" @tmp="" )="" {="" chomp="" ;="" s/^\s//;="" s/\s+$//;="" }="" my="" $addr_old="@tmp[0]" ;="" #="" #="" send="" mail="" and="" memorise="" last="" adresse="" if="" both="" are="" different="" #="" if="" (="" $addr="" ne="" $addr_old="" )="" {="" print="" "send="" mail="" ...\n"="" ;="" foreach="" my="" $mail_dest="" (="" @mail_det="" )="" {="" my="" $mail="Net::SMTP-">new($mail_srv) ;
$mail->mail($mail_src) ;
$mail->to($mail_dest);
$mail->data() ;
$mail->datasend("To:".$mail_dest."\n") ;
$mail->datasend("From:".$mail_src."\n") ;
$mail->datasend("Subject: Adresse IP\n") ;
$mail->datasend("\n") ;
$mail->datasend($addr."\n") ;
$mail->dataend() ;
$mail->quit() ;
}
$cmd = "echo ".$addr." > /tmp/wan_addr_flag" ;
`$cmd` ;
}
exit 0 ;
>>>>>>>>>>>>>>>>>>> The end