title: How to get the LAN IP of a client using Java?
body: <p>How can i get the LAN IP-address of a computer using Java? I want the IP-address which is connected to the router and the rest of the network.</p>
  
  <p>I've tried something like this:</p>
  
  <pre><code>Socket s = new Socket("www.google.com", 80);
  String ip = s.getLocalAddress().getHostAddress();
  s.close();
  </code></pre>
  
  <p>This seem to work on some cases, but sometimes it returns the loopback-address or something completely different. Also, it requires internet connection.</p>
  
  <p>Does anyone got a more accurate method of doing this?</p>
  
  <p><strong>EDIT:</strong> Thought it would be better to ask here than in a comment..</p>
  
  <p>What if you got many interfaces? For example, one for cable, one for wifi and one for virtual box or so. Is it impossible to actually see which one is connected to the network?</p>