title: How can I get the IP address of a (Linux) machine?
body: <p>This Question is almost the same as the previously asked <a href="https://stackoverflow.com/questions/122208/get-the-ip-address-of-local-computer">How can I get the IP Address of a local computer?</a> -Question. However I need to find the IP address(es) of a <strong>Linux Machine</strong>.</p>
  <p>So: How do I - programmatically in <strong>C++</strong> - detect the IP addresses of the linux server my application is running on. The servers will have at least two IP addresses and I need a specific one (the one in a given network (the public one)).</p>
  <p>I'm sure there is a simple function to do that - but where?</p>
  <hr />
  <p>To make things a bit clearer:</p>
  <ul>
  <li>The server will obviously have the &quot;localhost&quot;: 127.0.0.1</li>
  <li>The server will have an internal (management) IP address: 172.16.x.x</li>
  <li>The server will have an external (public) IP address: 80.190.x.x</li>
  </ul>
  <p>I need to find the external IP address to bind my application to it. Obviously I can also bind to INADDR_ANY (and actually that's what I do at the moment). I would prefer to detect the public address, though.</p>