If you need to be notified upon the IP address of the system it can be achieved through following Perl Script
At first a sendemail needs to be installed using : sudo apt-get install sendmail (in Debian based Distros)
Else you may use another MTAs too like sendmail or postfix that is available.
#!/usr/bin/perl -w
#Anwesh Tiwari Oct 12 2011
use strict;
my $today=`date +%Y-%m-%d" "%r`;
#location of TEMP file
my $ip_last_check_file = "/home/tmp/IP-Address";
my $ip_now = `curl -s http://checkip.dyndns.org`;
$ip_now =~ s/.*?(\d+\.\d+\.\d+\.\d+).*/$1/s;
open(IP, "<$ip_last_check_file") or die "Cannot open $ip_last_check_file: $!";
my $ip_last_check = <IP>;0
close(IP);
if ($ip_now ne $ip_last_check)
{
open(IP, ">$ip_last_check_file") or die "Cannot open $ip_last_check: $!";
print IP $ip_now;
close(IP);
#-s "SMTP address of your SMTP server instead" of "-s localhost" if you dont have ipaddress running.
my $output = `sendemail -f sentname\@yourdomain.com -t alertaddress\@yourdomain.com -s localhost -u IP-CHANGE-ALERT -m Gateway IP-address has changed to $ip_now.\\\\n Event Time :$today`;
}
exit;
Blog Archive
-
►
2010
(79)
-
►
June
(11)
- Protect Web Directories using .htacess
- eth0_rename in ethernet card
- Reset windows password using linux live CD
- IPP printer configuration in windows
- Reinstall WIndows Fax and Picture viewer
- Stream audio in Bluetooth Headset using Dongle
- Convert image files to text
- Configuring exim4 in Ubuntu to use GMail for SMTP
- Change apache2 web directory
- Checking webserver vulnerabilities
-
►
June
(11)
Wednesday, October 19, 2011
Subscribe to:
Post Comments (Atom)


0 comments:
Post a Comment