![]() |
|
|
|||||||
![]() |
Java - How to get you Extenal/Real IP (Router) |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Homer wrote:
> > I am writing a code as a Java Application (not Applet or Servlet) and I > am trying to find out what is my real IP address (not 192.168. one). I > am behind my LinkSys router and everything I try I still get 192.168. The 192.168.. address is the real IP address of your machine. To get the IP address of the other side of your NAT router will be router dependent. For my D-Link router, I'd have to login to the administration pages and find the IP address amongst the JavaScript. Tom Hawtin -- Unemployed English Java programmer http://jroller.com/page/tackline/ Thomas Hawtin |
|
|
|
|
#2 |
|
Posts: n/a
|
Hi All,
I am writing a code as a Java Application (not Applet or Servlet) and I am trying to find out what is my real IP address (not 192.168. one). I am behind my LinkSys router and everything I try I still get 192.168. I have tried: - InetAddress: Always returns 192.168 address (unless I am missing something). - Open Socket to www.cnn.com,80 and read local address (still 192.16 - I am reading about Upnp but not sure if that's the way I can ask my Router about my real IP. - Calling http://www.whatismyip.com and parse the result seems too strange. Any idea? Thanks in advance, Homer |
|
|
|
#3 |
|
Posts: n/a
|
On Mon, 2006-04-17 at 11:36 -0700, Homer wrote:
> > - Calling http://www.whatismyip.com and parse the result seems too > strange. You can't do it reliably without querying some service that can see the remote address of the connection, and that means something outside your gateway. That's why webservices like that are needed, otherwise the browser would be able to give you the info. Why do you need the "real" address? If it's not something you can put in DNS (and reverse DNS), how do you know it won't change between calls to your function? |
|
|
|
#4 |
|
Posts: n/a
|
> - Calling http://www.whatismyip.com and parse the result seems too > strange. Why's that so bad? Using a Web Service seems to be a good way to solve your problem - just make sure that you can exchange the service easily if it is removed for one reason or another. /philipp |
|
|
|
#5 |
|
Posts: n/a
|
Homer wrote:
> Hi All, > > I am writing a code as a Java Application (not Applet or Servlet) and I > am trying to find out what is my real IP address (not 192.168. one). I > am behind my LinkSys router and everything I try I still get 192.168. > Visit grc.com or crypto.yashy.com/nmap.php - both are web sites and will report your firewall's external IP. -- martin@ | Martin Gregorie gregorie. | Essex, UK org | |
|
|
|
#6 |
|
Posts: n/a
|
To answer to question "why do I need external IP address?":
I have a website hosted somewhere for a little bit of money. The problem is that hosting company doesn't support PHP, MySql,.... (that I need for my FamilyTree software) I have DSL connection as home and I put some small html pages on hosting site to forward all Not-Supported requests to my home web server. Inside those small-html-files I have my dynamic home ip address and I need to change it whenever my ip address changes. 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 know that it looks a bit ugly, but it's free and it's working (with up to 5 sec delay). |
|
|
|
#7 |
|
Posts: n/a
|
"Homer" <> wrote in message news: oups.com... > To answer to question "why do I need external IP address?": > > I have a website hosted somewhere for a little bit of money. The > problem is that hosting company doesn't support PHP, MySql,.... (that > I need for my FamilyTree software) > I have DSL connection as home and I put some small html pages on > hosting site to forward all Not-Supported requests to my home web > server. > Inside those small-html-files I have my dynamic home ip address and I > need to change it whenever my ip address changes. > > 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 know that it looks a bit ugly, but it's free and it's working > (with up to 5 sec delay). > Have you considered using a service like no-ip.com? - Oliver |
|
|
|
#8 |
|
Posts: n/a
|
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. |
|
|
|
#9 |
|
Posts: n/a
|
"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. no-ip.com provides different services. The so called "Free" service is free. See http://www.no-ip.com/services/manage...namic_dns.html 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. I used to use the free service, but eventually I just bought a domain name and a static IP. - Oliver |
|
|
|
#10 |
|
Posts: n/a
|
Homer wrote:
> Nope. I know it's cheap but is not free. No-ip.com is free, I've been using it at work for ages and it's still free. Also dyndns.org is free. I actually recommend dyndns.org, because they provide you with a free download called noipDuc (or similar) that runs on your machine and updates their DNS servers whenever your external IP changes. Also, my wireless router (Linksys WRT54G) has a feature in the admin web pages to allow auto updating of your dyndns address, so I don't even have to run noipDuc on my desktop machine any more. > 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'd seriously avoid doing this in your own code - I appreciate it works, but it seems inelegant, when dyndns.org works so well and is free. |
|