ifconfig in python

James Mills prologic at shortcircuit.net.au
Tue Jan 20 01:34:04 CET 2009

On Tue, Jan 20, 2009 at 10:28 AM, Nehemiah Dacres <vivacarlie at gmail.com> wrote:
> Is ther an easy way to get the resolved ip address of the machine a script
> is running on? socket.gethostbyname(socket.gethostname) has only returned
> the ip address of my loop back interface ... not very usefull.

That's because your /etc/hosts resolves
your hostname to :)

And no I know of no "easy" way cross
platform way. Perhaps parsing the output
of ifconfig itself ?


More information about the Python-list mailing list