dslreports logo
site
 
    All Forums Hot Topics Gallery
spc

spacer




how-to block ads


Search Topic:
uniqs
4283
share rss forum feed


aa2k

join:2000-10-06
Damascus, MD

new automation address for a script to find public ip?

Hi,
Quick question.. for some years I had a script in my linux box to run once every hour to check my public IP, if the IP changed then I get an email saying with my new IP address is (I use dynamic IP).
My script appointed to the site:
»www.whatismyip.com/membership-options/

But now they have changed the rules and now there is a need to register, the free account only allows 12 ip check per day, I am looking for another trusted/free with no need of registration site to check so I can change my script (or use a new one),

When my script runs I get the following in response:
We have removed the .asp version of this script from our website. Please click here to learn about our new "Automation" services.


any suggestions?

The script I use now is:

 
#!/usr/bin/perl
$IP_FILE = "/home/ipemail.result";
 
my $newip = `wget http://automation.whatismyip.com/n09230945.asp -O - -q`;
my $oldip = getoldip();
 
my $send_to = "To: my\@email-here.com\n";
my $reply_to = "Reply-to: my\@email-here.com\n";
my $from = "From: my\@email-here.com\n";
my $subject = "Subject: IP Address: $newip\n";
my $content = "<h1>$newip</h1>";
if($newip ne $oldip)
{
   writenewip($newip);
   unless(open (MAIL, "|/usr/sbin/sendmail my\@email-here.com"))
   {
      print "error.\n";
      warn "Error starting sendmail: $!";
   }
   else{
      print MAIL $from;
      print MAIL $reply_to;
      print MAIL $subject;
      print MAIL $send_to;
      print MAIL "Content-type: text/html\n\n";
      print MAIL $content;
      close(MAIL) || warn "Error closing mail: $!";
      print "Mail sent\n";
   }
}
 
sub writenewip
{
   my($newip) = @_;
   print ("new IP = $newip\n");
   open IPFILE, ">$IP_FILE";
   print IPFILE "$newip\n";
   close IPFILE;
}
 
sub getoldip
{
   open IPFILE, "$IP_FILE";
   my($line) = 0;
   while ( <IPFILE> )
   {
      chomp;
      $line = $_;
   }
   close IPFILE;
   return($line);
}
 
 

Thanks!


PMAdmin

@charter.com

Hi, feel free to use my site.

Change this:

my $newip = `wget http://automation.whatismyip.com/n09230945.asp -O - -q`;
 

To this:
my $newip = `wget https://www.packetmail.net/myip.php -O - -q`;
 

Look, I'm open source:

 

Cheers.


PMAdmin

@charter.com

Seems the PHP was stripped despite using the code tags. Using HTML entities below.

<?php echo htmlentities(getenv("REMOTE_ADDR"))."\n"; die; ?>



Bill_MI
Bill In Michigan
Premium,MVM
join:2001-01-03
Royal Oak, MI
kudos:2
Reviews:
·WOW Internet and..
reply to aa2k

In case it helps, here's what's still working from an old list I have:

»checkip.dyndns.org/
»checkip.dyndns.org:8245/
»dynamic.zoneedit.com/checkip.html
»dynupdate.no-ip.com/ip.php

This list was about a dozen addresses a dozen years ago.


pablo
MVM
join:2003-06-23
kudos:1
reply to aa2k

Hi,

Just for fun, I thought I'd take your concept and re-write the script using »checkip.dhndns.org:

wget --quiet -O - http://checkip.dyndns.org | sed -e 's/^.*Current IP Address: //g' -e 's/<.*$//g'
 

Cheers,
-pablo

--
openSUSE 12.2/KDE 4.x
ISP: TekSavvy Bonded DSL; backhauled via a 6KM wireless link
Assorted goodies: »pablo.blog.blueoakdb.com


aa2k

join:2000-10-06
Damascus, MD
reply to aa2k

Thanks guys!! this helps me a lot!!!! I really appreciate it.



houkouonchi

join:2002-07-22
Ontario, CA
Reviews:
·Verizon FiOS
reply to aa2k

if you want u can use »box.houkouonchi.jp/ip.php too. A real simple PHP script I wrote and the machine is at a data center and pretty much on/accessible 365 days a year.
--
300/150 mbit Bonded Verizon FiOS connection FTW!



nwrickert
sand groper
Premium,MVM
join:2004-09-04
Geneva, IL
kudos:7
Reviews:
·AT&T U-Verse
reply to aa2k

For several years, I have been using a script that queries my router and/or dsl modem (when I was on dsl). The script has to be tailored to the particular router. For some routers, I had to use an expect script, because I could only get that info from the router after login. Other routers will give out WAN information without login, so I just piped the output of "lynx" to a sed script to extract the wanted information.

This all avoids having to go outside the LAN.

Before I started doing it that way, my script simply did an SSH login to a work computer, which then did "echo $SSH_CLIENT" and I extracted my public IP info from that.

And then there's the page "http://www.dslreports.com/whois" at DSLR which gives your IP address. Maybe "lynx" or "wget" of that page will provide what you want.
--
AT&T Uverse; Zyxel NBG334W router (behind the 2wire gateway); openSuSE 12.2; firefox 18.0



Black Box

join:2002-12-21
reply to aa2k

If you have an PHP enable website somewhere create a page called, say, ip.php with the following contents:
php code:

<?
echo $_SERVER[REMOTE_ADDR];
?>
It will give you the IP used to call it from your script.

--
Keep It Safe, Stupid!
Yes, I CanChat. Can You?