Trying to find the external IP address of my machine

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

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • 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.
    17,800 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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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

Following