How to get IP address
exarkun at intarweb.us
Sun Mar 2 19:22:12 CET 2003
On Sun, Mar 02, 2003 at 03:06:06PM +0100, Nagy L?szl? Zsolt wrote:
> 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 writting a program
> that assigns a DNS name to a given IP address. So my hostname may have a
> bad IP address assigned at the time when I need the IP address. IP address
> is a lower level than DNS name. I can have an IP address without hostname.
> Can you tell me a solution in the case when I have no valid DNS name?
There's a hackish solution that somewhat works -
s = socket.socket()
dottedQuad = s.getsockname()
I recommend using something like your ISPs news or email server for the
arbitrary host and port, since these will usually be fast to connect to.
up 21 days, 22:29, 6 users, load average: 0.25, 0.46, 0.44
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 196 bytes
Desc: not available
More information about the Python-list