title: Python - Get localhost IP
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/166506/finding-local-ip-addresses-using-pythons-stdlib">Finding local IP addresses using Python&#39;s stdlib</a>  </p>
  </blockquote>
  
  
  
  <p>To get my localhost IP address I do <code>socket.gethostbyname(socket.gethostname())</code>. But it gives me the answer <code>127.0.0.1</code>.
  If I do <code>an_existing_socket.getsockname()[0]</code> I get the answer <code>0.0.0.0</code>.</p>
  
  <p>I need my 'real' ip address (for instance 192.168.x.x) to modify a configuration file. How could I get it?</p>