Re: get the IP address of a host

2005-01-07 Thread Jorge Luiz Godoy Filho
Kartic, Quarta 05 Janeiro 2005 14:08, wrote: > socket.gethostbyaddr(socket.gethostname()) > > will return a tuple containing fully qualified hostname, alternative > hostnames, ip addresses (>1 if multihomed). > > or > > socket.gethostbyname(socket.gethostname()) None of these work with compute

Re: get the IP address of a host

2005-01-06 Thread J Berends
Jp Calderone wrote: On Thu, 06 Jan 2005 14:35:16 +0100, J Berends <[EMAIL PROTECTED]> wrote: From several approached I came up with the following code: def getipaddr(hostname='default'): """Given a hostname, perform a standard (forward) lookup and return a list of IP addresses for that host

Re: get the IP address of a host

2005-01-06 Thread Jp Calderone
On Thu, 06 Jan 2005 14:35:16 +0100, J Berends <[EMAIL PROTECTED]> wrote: > > From several approached I came up with the following code: > > def getipaddr(hostname='default'): > """Given a hostname, perform a standard (forward) lookup and return > a list of IP addresses for that host."""

Re: get the IP address of a host

2005-01-06 Thread P
J Berends wrote: def getipaddr(hostname='default'): [snip] It returns the IP address with which it connects to the world (not lo), might be a pvt LAN address or an internet routed IP. Depend on where the host is. I hate the google trick actually, so any suggestions to something better is always

Re: get the IP address of a host

2005-01-06 Thread Nick Coghlan
J Berends wrote: Lee Harr wrote: Basically, it scrapes the output from ifconfig for the actual address assigned to the interface. Works perfectly on FreeBSD and Linux (given the correct configuration). Nice way, have to device something for windows than. Use the same approach, but scrape the outpu

Re: get the IP address of a host

2005-01-06 Thread J Berends
Lee Harr wrote: I found that the socket solutions only work if your DNS entries are correct ... which in my case was not true. So I came up with this: That is indeed correct, and even if the DNS entries are correct at times it does not give the full list of IPs by gethostbyname or gethostbyaddr.

Re: get the IP address of a host

2005-01-05 Thread Lee Harr
On 2005-01-05, none <""> wrote: > I want to determine the outside (non local, a.k.a. 127.0.0.x) ip > addresses of my host. It seems that the socket module provides me with > some nifty tools for that but I cannot get it to work correctly it seems. > > Can someone enlightened show a light on this:

Re: get the IP address of a host

2005-01-05 Thread Kartic
or socket.gethostbyname(socket.gethostname()) -- http://mail.python.org/mailman/listinfo/python-list

Re: get the IP address of a host

2005-01-05 Thread Kartic
socket.gethostbyaddr(socket.gethostname()) will return a tuple containing fully qualified hostname, alternative hostnames, ip addresses (>1 if multihomed). Thanks, --Kartic -- http://mail.python.org/mailman/listinfo/python-list