Determine ip address

Simon Brunning simon.brunning at gmail.com
Fri Apr 15 09:19:14 EDT 2005


On 15 Apr 2005 06:03:06 -0700, codecraig <codecraig at gmail.com> wrote:
> hi,
>    how can i use python to figure the ip address of the machine which
> the python script is running on?  I dont mean like 127.0.0.1....but i
> want the external IP address (such as ipconfig on windows displays).

On Windows, this works:

socket.gethostbyname(socket.gethostname())

Is that OK on real operating systems too?

-- 
Cheers,
Simon B,
simon at brunningonline.net,
http://www.brunningonline.net/simon/blog/



More information about the Python-list mailing list