Reading my own ip-address

Matthew Dixon Cowles matt at mondoinfo.com
Tue May 29 19:27:37 EDT 2001


On Wed, 30 May 2001 00:00:06 +0200, Charlie Clark
<charlie at begeistert.org> wrote:

>I would like to know what the ip-adress of my dial-up connection is.

Charlie,
Because of the way TCP/IP is designed, there is no general solution
for doing that. If go to Google and search its Usenet archives for the
phrase "local ip" in comp.lang.python you'll find various explanations
and some techniques that may work in your situation.  Specifically,

socket.gethostbyaddr(socket.gethostname())[2][0]

May do what you want.

Regards,
Matt



More information about the Python-list mailing list