Trying to find the external IP address of my machine

413315 pts.
Tags:
IP address
Networking
I'm trying to figure out how to get the external IP address of my machine (as a computer from outside my network would get it). The following only gives me the local IP address of the machine. Thanks!
public class IPAddress {

  private InetAddress thisIp;

  private String thisIpAddress;

  private void setIpAdd()
  {
    try
    {
       InetAddress thisIp = InetAddress.getLocalHost();
       thisIpAddress = thisIp.getHostAddress().toString();
    }
    catch(Exception e){}
  }

  protected String getIpAddress()
  {
     setIpAdd();
     return thisIpAddress;
  }

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Kevin Beaver
    Are you trying to automate this programatically? Or do you just need to know your external IP address? A simple browse over to www.whatismyip.com will work for the latter and I don't see why the same thing couldn't be implemented pretty easily with code.
    21,085 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: