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-17-2006, 05:59 PM   #1
Default Re: How to get you Extenal/Real IP (Router)


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
  Reply With Quote
Old 04-17-2006, 06:36 PM   #2
Homer
 
Posts: n/a
Default How to get you Extenal/Real IP (Router)

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

  Reply With Quote
Old 04-17-2006, 06:52 PM   #3
James McGill
 
Posts: n/a
Default Re: How to get you Extenal/Real IP (Router)

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?

  Reply With Quote
Old 04-17-2006, 07:36 PM   #4
Philipp Leitner
 
Posts: n/a
Default Re: How to get you Extenal/Real IP (Router)


> - 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
  Reply With Quote
Old 04-17-2006, 07:44 PM   #5
Martin Gregorie
 
Posts: n/a
Default Re: How to get you Extenal/Real IP (Router)

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 |
  Reply With Quote
Old 04-17-2006, 07:56 PM   #6
Homer
 
Posts: n/a
Default Re: How to get you Extenal/Real IP (Router)

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).

  Reply With Quote
Old 04-17-2006, 07:59 PM   #7
Oliver Wong
 
Posts: n/a
Default Re: How to get you Extenal/Real IP (Router)


"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

  Reply With Quote
Old 04-17-2006, 08:26 PM   #8
Homer
 
Posts: n/a
Default Re: How to get you Extenal/Real IP (Router)

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.

  Reply With Quote
Old 04-17-2006, 09:13 PM   #9
Oliver Wong
 
Posts: n/a
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.


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

  Reply With Quote
Old 04-17-2006, 10:54 PM   #10
Alex Hunsley
 
Posts: n/a
Default Re: How to get you Extenal/Real IP (Router)

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.
  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
Forum Jump