title: External IP Address of the client
body: <p>Sounds funny, but how can I get the external IP address from a client?</p>
  
  <p>I tried few things, but didn't work for me.</p>
  
  <p>in first place I tried </p>
  
  <pre><code>request.getRemoteAddr()
  </code></pre>
  
  <p>and I am getting the result as: 0:0:0:0:0:0:0:1</p>
  
  <p>in second place I tried </p>
  
  <pre><code>InetAddress ip = InetAddress.getLocalHost();
  ip.getHostAddress());
  </code></pre>
  
  <p>and I am getting the result as: 127.0.0.1</p>
  
  <p>in third place I tried</p>
  
  <pre><code>        URL whatismyip = new URL("http://checkip.dyndns.org:8245/");
          BufferedReader inIP = new BufferedReader(new InputStreamReader(whatismyip.openStream()));
  
          String IPStrOld = inIP.readLine(); //IP as a String
          String IPStrNewest = IPStrOld.replace("&lt;html&gt;&lt;head&gt;&lt;title&gt;Current IP Check&lt;/title&gt;&lt;/head&gt;&lt;body&gt;Current IP Address: ", "");
          String IPStr = IPStrNewest.replace("&lt;/body&gt;&lt;/html&gt;", "");
  </code></pre>
  
  <p>but I get the external IP of the server only</p>
  
  <p>and for the last place</p>
  
  <pre><code>        URL whatismyip = new URL("http://automation.whatismyip.com/n09230945.asp");
          BufferedReader inIP = new BufferedReader(new InputStreamReader(whatismyip.openStream()));
          String ip = inIP.readLine();
  </code></pre>
  
  <p>this is the same, I get the external IP of the server only</p>
  
  <p>So, what's the deal?</p>