How to get IP address

Donn Cave donn at
Mon Mar 3 18:11:54 CET 2003

Quoth Nagy_Lszl_Zsolt <nagylzs at>:
| Sorry, but this does not help me. I want to determine the IP address
| because I want to send my external
| IP address to a dynamic DNS provider (in an A record). I get my IP
| address with DHCP and I'm ...

What I have done in this case is connect to a remote service and
use getsockname() to return the actual IP.  (getsockname is a
method of the socket object.)

I use the DNS service that's configured in my TCP setup - not because
this has anything to do with DNS, it's just the most basic IP address
I know from first principles.  If that doesn't work, then I'm a goner
anyway.  This is still mildly platform dependent, as there is no
standard way to determine this TCP configuration parameter, but at
worst you can solve this by hand per installation.

	Donn Cave, donn at

More information about the Python-list mailing list