![]() |
|
|
|||||||
![]() |
Java - How to get you Extenal/Real IP (Router) |
|
|
Thread Tools | Search this Thread |
|
|
#11 |
|
"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 |
|
|
|
|
#12 |
|
Posts: n/a
|
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 |
|
|
|
#13 |
|
Posts: n/a
|
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 |
|
|
|
#14 |
|
Posts: n/a
|
"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 |
|
|
|
#15 |
|
Posts: n/a
|
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 |
|
|
|
#16 |
|
Posts: n/a
|
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 |
|
|
|
#17 |
|
Posts: n/a
|
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 |
|
|
|
#18 |
|
Posts: n/a
|
"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 |
|
![]() |
| Thread Tools | Search this Thread |
|
|
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 |