Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Best way to post dynamic IP addresses to the web?

Best way to post dynamic IP addresses to the web?
Thread Tools
Fresh-Faced Recruit
Join Date: Nov 2001
Status: Offline
Reply With Quote
Jan 10, 2003, 02:42 AM
 
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
Reply With Quote
Jan 10, 2003, 04:43 AM
 
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.
     
Zim
Senior User
Join Date: Apr 2001
Location: Cary, NC
Status: Offline
Reply With Quote
Jan 10, 2003, 07:38 AM
 
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
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:02 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2