From: Victor Cappuccio (cvictor@protokolgroup.com)
Date: Mon Apr 10 2006 - 16:17:41 ART
Tim, Thank you very much, the script worked like it should..
I just changed the language of the email and the email looks looks  
like this
IPProxyLinux@protokolgroup.com escribis:
> LA IP CAMBIO
> Vieja:  XX.XX.96.117
> Nueva: XXX.XX.96.117
Thanks again..
Tim Fletcher escribis:
> Victor,
>
> Here's a perl script I wrote that uses SNMP. The 1st time you run  
> it, it gets your IP address and stores it in a file. Each time you  
> run it after that, it checks the current IP against the cached one.  
> If it's different, it sends out an e-mail.
>
> You'll need 2 perl modules; Net::SNMP and Mail::Send. Try running  
> the script 1st. If it says it can't find one of these modules, you  
> can install them using cpan. Log in as root, and from the command  
> line enter "cpan". It may ask you a bunch of setup questions. Once  
> you get to the "cpan>" prompt, enter "install Net::SNMP". Once that  
> completes, do the same thing for Mail::Send, then enter "q" to  
> quit. Once you have the script working, put in /etc/cron.hourly.
>
> -Tim Fletcher
>
> #!/usr/bin/perl -w
>
> use strict;
> use Net::SNMP;
> use Mail::Send;
>
> # the IP address that you use to connect to your gateway
> my $host           = '<IPaddr>';
>
> # the name of your external interface such as "Ethernet0/0"
> my $interface      = 'PIX Firewall \'outside\' interface';
>
> # your SNMP community string
> my $community      = '<community>';
>
> # who the mail will be sent to
> my $rcpt           = '<recipient>';
>
> # the from address of the mail
> my $mail           = '<sender>';
>
> # a writable file to store the current IP address
> my $cache_file     = '/tmp/ext_ip_addr';
>
> my $ifDescr        = '.1.3.6.1.2.1.2.2.1.2';
> my $ipAdEntIfIndex = '.1.3.6.1.2.1.4.20.1.2.';
>
> my ($sess,
>    $err,
>    $fh,
>    $int_list,
>    $int_idx,
>    $msg,
>    $new_addr,
>    $old_addr,
>    %int_name,
>    %int_ip_addr,
> );
>
> $\ = "\n";
>
> # read cach file it it exists
> if (open (CF, $cache_file)) {
>  chomp ($old_addr = <CF>);
>  close CF;
> }
>
> # open SNMP session
> ($sess, $err) = Net::SNMP->session(Hostname  => $host,
>                                   Community => $community);
> die "session error: $err\n" unless defined $sess;
>
> # get the list of interfaces
> $int_list = $sess->get_table(Baseoid => $ifDescr);
> unless (defined $int_list) {
>  $err = $sess->error;
>  die "get_table error: $err\n";
> }
>
> # find the interface index using the interface name
> foreach (keys %$int_list) {
>  # get the last field of the OID
>  my $idx_num = (split (/\./, $_))[11];
>
>  # $int_name{<index number>} = <interface name>
>  $int_name{$idx_num} = $int_list->{$_};
>
>  $int_idx = $idx_num if $int_list->{$_} eq $interface;
> }
>
> # make sure we matched the interface name
> die "$0: could not find interface named: $interface" unless defined  
> $int_idx;
>
> # find the address using the interface index
> $int_list = $sess->get_table(Baseoid => $ipAdEntIfIndex);
>
> unless (defined $int_list) {
>  $err = $sess->error;
>  die "get_table error: $err\n";
> }
>
> # extract the ip address from the OID using the index
> foreach (keys %$int_list) {
>  my $addr = join ('.', (split (/\./, $_))[11 .. 14]);
>  $int_ip_addr{$_} = $addr;
>  $new_addr = $addr if $int_list->{$_} eq $int_idx;
> }
>
> $sess->close;
>
> # update cache file
> open (CF, ">" . $cache_file)
>                || die "error opening $cache_file for writing: $?\n";
> print CF $new_addr;
> close CF || die "error closing $cache_file: $?\n";
>
> # if there was no previous cache file, exit now
> exit unless defined $old_addr;
>
> # if the address hasn't changed, exit now
> exit if ($old_addr eq $new_addr);
>
> # if we're runnning interactively, print results
> if (-t STDOUT) {
>  print "Old address: $old_addr";
>  print "New address: $new_addr";
> }
>
> # send e-mail
> $msg = new Mail::Send;
> $msg->to($rcpt);
> $msg->add('From', $mail);
> $msg->subject('IP address change');
>
> $fh = $msg->open;
> print $fh "Public IP address has changed";
> print $fh "Old address: $old_addr";
> print $fh "New address: $new_addr";
> $fh->close;
>
>
> Victor Cappuccio wrote:
>> Wayne, THANKS :D
>> what Linux app could help me doing that??
>>
>>
>> CCIE KH49279 escribis:
>>> Victor,
>>>
>>> If you have a linux box on your internal network, you can have it  
>>> poll the
>>> router and email the new IP when it changes. I am assuming you  
>>> are using
>>> DHCP on the router. Perhaps you can setup logging??
>>>
>>> wayne
>>> -----Original Message-----
>>> From: nobody@groupstudy.com [mailto:nobody@groupstudy.com] On  
>>> Behalf Of
>>> Victor Cappuccio
>>> Sent: Sunday, April 09, 2006 1:48 AM
>>> To: Magmax
>>> Cc: CCIE LAB
>>> Subject: Re: a night with an IP
>>>
>>>  Ubaid, I do not get your question...
>>>
>>> I'm located in Venezuela
>>> But from the link you gave me, I'm located in this IP  
>>> Address :D :D :D :D
>>>
>>> You appear to be located in United States [City: Caracas, Distrito
>>> Federal], based on your IP address of 1xx.2xx.63.3 (see our  
>>> geolocation
>>> FAQ for details). FAQ, media information, linking, automated  
>>> usage and
>>> more can be found at the FAQ page. Comments? Suggestions for new
>>> features? Problems? Want DNS advice? Please use the DNSstuff.com  
>>> Forums.
>>>
>>> When did Venezuela became part of the US :D
>>> That are good new, since I would not need a Visa to get in :D
>>>
>>> Now my question is, is there any Cisco Method to know what IP  
>>> Address my
>>> TS has and send like an TRAP to an email?
>>>
>>> Magmax escribis:
>>>
>>>   Can you tell me where are you and how are you sending this  
>>> email and where
>>>   is your rack?
>>>     Ubaid
>>>
>>>   -----Original Message-----
>>>   From:   nobody@groupstudy.com    
>>> [  mailto:nobody@groupstudy.com  ] On
>>> Behalf Of
>>>   Victor Cappuccio
>>>   Sent: Sunday, 9 April 2006 4:32 PM
>>>   To: Magmax
>>>   Cc: 'CCIE LAB'
>>>   Subject: Re: a night with an IP
>>>     Thanks Magmax, but I do not know my current RACK IP  
>>> Address... :(
>>>
>>>   Magmax escribis:
>>>
>>>     You can try using Mirc or visit this website to find your  
>>> current ip
>>>
>>>   address
>>>
>>>     http://www.dnsstuff.com/        -----Original Message-----
>>>     From:     nobody@groupstudy.com      
>>> [    mailto:nobody@groupstudy.com
>>> ] On Behalf Of
>>>     Victor Cappuccio
>>>     Sent: Sunday, 9 April 2006 4:16 PM
>>>     To: CCIE LAB
>>>     Subject: a night with an IP         Hello all
>>>         I have a little Lab with n Routers connected to a  
>>> Terminal Server, and     the Terminal Server connected directly  
>>> to the Internet, who constantly     changes the IP Address by a  
>>> remote process in the ISP
>>>         Now is there any way to know what IP Address this poor's  
>>> men rack have     now? Maybe something like sending an Email to  
>>> the Admin (me :D) or any     other method that could be nice to  
>>> know what IP Address I have now?
>>>         ISP Told me that they do not give up that information, so  
>>> I must wait     until Monday to play with my routers :(
>>>         Thanks
>>>     Victor.
>>>          
>>> ____________________________________________________________________ 
>>> ___
>>>     Subscription information may be found at:
>>> http://www.groupstudy.com/list/CCIELab.html            
>>> ____________________________________________________________________ 
>>> ___
>>>   Subscription information may be found at:
>>> http://www.groupstudy.com/list/CCIELab.html  
>>> ____________________________________________________________________ 
>>> ___
>>> Subscription information may be found at: http:// 
>>> www.groupstudy.com/list/CCIELab.html
>>
>> _____________________________________________________________________ 
>> __
>> Subscription information may be found at: http:// 
>> www.groupstudy.com/list/CCIELab.html
This archive was generated by hypermail 2.1.4 : Tue May 01 2007 - 08:28:38 ART