How to get IP address

Donn Cave donn at u.washington.edu
Mon Mar 3 12:11:54 EST 2003


Quoth Nagy_Lszl_Zsolt <nagylzs at freemail.hu>:
...
| 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 u.washington.edu




More information about the Python-list mailing list