Clean way to get one's network IP address?

Gilles Ganault nospam at
Wed Nov 21 16:15:43 CET 2007


I need to get the local computer's IP address, ie. what's displayed
when running "ifconfig" in Linux:

# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:15:58:A1:D5:6F  
          inet addr:  Bcast:

I know about socket.gethostbyname, but this relies on what's in
/etc/hosts, and I'd rather have a more independent solution.

What would be a good way to do this?

Thank you.

More information about the Python-list mailing list