What Is My IP Address? - IP Address Lookup, Bandwidth Speed Test, IP Info, plus more

Go Back   What Is My IP Forum > All About Code > Coding Problems

Notices


Closed Thread
 
Thread Tools Display Modes
  #1  
Old 08-04-2008, 07:44 PM
frontbenchguys frontbenchguys is offline
Member
 
Join Date: Aug 2008
Location: India
Posts: 4
Default Finding Dynamic IP using Java

Hi,

My computer(single) is connected to internet through an ISP Provider (DSL connection via Ethernet). I get the IP dynamically when i connect to Internet. It is not same as my static IP that i gave during setup. I found the dynamic IP from whatismyip.com. Thanks to it. Now i need to find my dynamic IP using Java code. I tried with "InetAddress" class but all classes shows only my static IP. how to do it?

Thankyou
  #2  
Old 08-04-2008, 10:02 PM
clanmills's Avatar
clanmills clanmills is offline
Super Moderator
 
Join Date: Jul 2008
Location: San Jose, CA
Posts: 191
Send a message via MSN to clanmills Send a message via Skype™ to clanmills
Default

Your machine has an IP address on the local area network (LAN), and your network has a different address on the Internet (Wide Area Network, or WAN). The WAN address is provided by your ISP. You can configure your own LAN.

The conversion from the WAN to LAN is achieved by your router. So your code (be it in Java, Perl, Python or whatever) can only obtain the machine address (from the LAN). It will need to speak to a device on the WAN to obtain your WAN IP.

You could curl your network from the internet. The command:
Code:
curl http://whatismyip.com/automation/n09230945NL.asp
will do the business.

Here's some Java code which works for me:http://www.computing.dcu.ie/~humphry...orks/java.html

Last edited by clanmills; 08-04-2008 at 11:02 PM.. Reason: add the java url
  #3  
Old 08-05-2008, 07:33 AM
frontbenchguys frontbenchguys is offline
Member
 
Join Date: Aug 2008
Location: India
Posts: 4
Default Thankyou so much

Hi Mr. clanmills

Your suggestion is very useful to me.
I am happy with your immediate response.
Thank you. Thank you very much.
Closed Thread

Bookmarks


Thread Tools
Display Modes

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


All times are GMT -4. The time now is 08:55 PM.


What Is My IP - IP Command Lines - What is an IP Address - Speed Test - IP Address FAQ

Need IP address location detection service? Get it from IP2Location.com now.

Powered by vBulletin®
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright - WhatIsMyIP.com