Go Back   Velocity Reviews > Newsgroups > Java
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Java - How to get you Extenal/Real IP (Router)

 
Thread Tools Search this Thread
Old 04-18-2006, 12:16 AM   #11
Default Re: How to get you Extenal/Real IP (Router)



"Homer" <> wrote in message
news: ups.com...
> Nope. I know it's cheap but is not free.
> And my code is working. I just want to make it better. I can even put
> some code in my Hosting server to return my IP address instead of using
> whatismyip.com.
>


I have created another solution that works pretty well, and it is entirely
self-contained (ie, no third-party software or fees).

I have a small program running on my home server (Sun Netra). It's actually
two threads: one is a mini-server, which listens on a local port; the other
will access that port every few minutes, at my last known IP address, asking
for a magic number. If the magic number is wrong, or there's no response
from the mini-server, then the IP must have changed, so the program will
then access a CGI script on my remote (paid-for) website. That CGI script
will extract my home IP from the request header, and save it to a file. It
will also return the IP address back to my home server, where it will be
saved to my "last known IP" file. So now my home IP is saved at both ends.

It gets better. I have another CGI script on my remote web-site, which acts
as another mini-server. When this one is accessed, it will open a
connection to my home server (it has the IP address, remember!), and will
pass the query portion of the request to the home server, where it will be
passed to Tomcat, which creates HTML from a mixture of JSP and Servlets.
And because the home server also knows the home IP, it can plug that IP
address into the newly-created pages. What this means in practice is that I
can create content which contains references to images (for example) that
are on my home machine. The address bar in the browser still points at my
remote website, while some (or all) of the content is here at home. And
even if my IP changes, the generated pages will always contain the correct
IP.





Amfur Kilnem
  Reply With Quote
Old 04-18-2006, 12:24 AM   #12
Roedy Green
 
Posts: n/a
Default Re: How to get you Extenal/Real IP (Router)
On Mon, 17 Apr 2006 18:59:22 +0100, Thomas Hawtin
<> wrote, quoted or indirectly quoted someone
who said :

> IP address of the other side of your NAT router will be router
>dependent.


I call that the FACE IP. To determine it, see
http://mindprod.com/jgloss/ip.html

--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.


Roedy Green
  Reply With Quote
Old 04-18-2006, 12:24 AM   #13
Roedy Green
 
Posts: n/a
Default Re: How to get you Extenal/Real IP (Router)
On Mon, 17 Apr 2006 21:13:38 GMT, "Oliver Wong" <>
wrote, quoted or indirectly quoted someone who said :

> On the other hand, the "Free" service is intended for "personal use
>only". Not sure how that fits in with your site (which I believe you
>mentioned makes a bit of money). You might want to read the contract
>carefully to see what is or isn't allowed.


there are a number of other such services. Check them out via
http://mindprod.com/jgloss/dyndns.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.


Roedy Green
  Reply With Quote
Old 04-18-2006, 07:32 AM   #14
David Segall
 
Posts: n/a
Default Re: How to get you Extenal/Real IP (Router)
"Homer" <> wrote:

>Now I wrote some code (working great): It runs as service
>(wrapper.tanukisoftware.org) and checks my external IP address every 5
>second (I am sending httpRequest to http://www.whatismyip.com and parse
>the response until I find a better solution). Then it pulls (ftp) my
>html files from hosting site, put the new IP and push them back into
>the site.

I like it! I do it the other way round by using my Dlink 624-S to
monitor the IP address and let ZoneEdit know if it changes. That part
is free but I pay an insignificant $11.00/year to have ZoneEdit
monitor my web site and switch over to my free ISP site if my server
is unreachable. I think your method is better because I could direct
all the plain HTML requests to my ISP making them faster and more
reliable and only redirect the stuff I cannot host there.

Would you mind sharing your code? If that's OK, perhaps you could send
it to david at segall dot net. The "Reply To" address is invalid.


David Segall
  Reply With Quote
Old 04-18-2006, 01:42 PM   #15
Homer
 
Posts: n/a
Default Re: How to get you Extenal/Real IP (Router)
Very cool. nice work (what do you think about my solution?).
I beleive those free services (like noip, dynip,..) are a bit slow
since it will take some time to update DNS servers everywhere.



Homer
  Reply With Quote
Old 04-18-2006, 01:55 PM   #16
Homer
 
Posts: n/a
Default Re: How to get you Extenal/Real IP (Router)
BTW. I can use this to return my IP: (just save it to something.cgi and
call it)

#!/usr/bin/perl

use warnings;
use strict;

use CGI qw/:standard/;

my $remote_ip = $ENV{'REMOTE_ADDR'};

print header;
print "Your IP is: $remote_ip\n";



Homer
  Reply With Quote
Old 04-18-2006, 03:03 PM   #17
Homer
 
Posts: n/a
Default Re: How to get you Extenal/Real IP (Router)
As an update: I put a small thread inside my code (I didn't want to run
another code) to listen to some port (socket accept) and also I added a
open socket line to my code (as a client). So I am checking everything
inside one peace of code. Everything is cool now. Thanks to Amfur for
his idea.



Homer
  Reply With Quote
Old 04-18-2006, 03:06 PM   #18
Amfur Kilnem
 
Posts: n/a
Default Re: How to get you Extenal/Real IP (Router)

"Homer" <> wrote in message
news: oups.com...
> Very cool. nice work (what do you think about my solution?).


I had tried the same thing, but accessing my remote server every few seconds
was generating huge log files.

My method generates no log files, and no internet traffic, until the IP
changes.




Amfur Kilnem
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
router to router edwardsmichael Hardware 5 10-31-2009 10:51 PM
Help configuring DP-311P Print Server with Verizon Wireless Router Surek Hardware 0 04-07-2009 12:23 AM
Problem Connecting Through Router Nobody404 General Help Related Topics 0 07-10-2007 11:28 PM
Adsl Router > Dual Wan Load Balancing Router > 24 port Switch Hub nazeth Hardware 0 03-28-2007 09:36 AM
Connecting dsl modem, switch and WiFi router RameshMeda Hardware 0 11-03-2006 01:58 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46