 |
 |
Best way to post dynamic IP addresses to the web?
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Nov 2001
Status:
Offline
|
|
I'm trying to find some program that'll email my current dynamic ip to a given address or upload it to a website. The two pieces of software I've found so far (DropIT and IPReporter) don't do the job -- I'm behind a router, so DropIT just sees my 192.168.1.X address, and for some reason IPReporter reports a different ip than my router shows me (I'm on earthlink dsl) -- I tried using the IPReporter IP to ssh to, but it doesn't work. The IP my router tells me, however, works fine.
Are there any good unix daemons I can have runnign that'll check my "real" ip periodically and upload them to a website?
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: May 1999
Location: San Jose, CA
Status:
Offline
|
|
I don't know of any script off hand, but it shouldn't be too hard to hack something together.
Traditionally, the best way to obtain your IP address is to query the router via SNMP.
Alternatively you may be able to use an external web site that reports your IP address.
Something like:
curl -s http://whatismyip.com | grep h1
will get you your IP address. You can then either embed this in a web page, pipe it into an email, or do whatever you like with it.
|
|
Gods don't kill people - people with Gods kill people.
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Apr 2001
Location: Cary, NC
Status:
Offline
|
|
Heh, I use dyndns, but every once in a while something gets out of sync, I did exactly what you describe...
its a perl script... and it needs Net::FTP installed (I think 'sudo cpan intall Net::FTP' will do it)
And I have it set to run on a cron job once/hour. (crontab -e)
59 * * * * /Users/zimmy/bin/ip.pl > /dev/null 2>&1
Code:
#!/usr/bin/perl -w
use strict;
use Cwd;
use Net::FTP;
my $ipfile = "/tmp/ip.html";
my $ip = "0.0.0.0";
my $ftp;
my $myip;
my $date = substr(scalar localtime,4,15);
open(IPFILE ,">$ipfile"); # open the csv-formatted calendar file
$ip = `/sbin/ifconfig -a | grep broadcast`;
($myip) = ($ip =~ m/inet\s+(\d+\.\d+\.\d+\.\d+)\s+netmask/);
print IPFILE "<html><head><title>IP Addr</title></head>
<body>
<p>$myip</p>
<p>updated: $date</p>
</body></html>\n";
close(IPFILE);
$ftp = Net::FTP->new("your.website.com",
Timeout => 30,
Debug => 1,
Passive => 1) or die "Can't connect $@\n";
$ftp->login("username","password") or die "Could not login";
$ftp->put($ipfile,"ip.html") or die "Can't send ip.html $!\n";
$ftp->quit();
unlink("$ipfile");
You can now get your current IP addr by going to
http://your.website.com/ip.html
Also useful as a sanity check when you can't reach your machine.. if you see it still updating the remote website, you know its still alive.
Hope this helps,
Mike
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|