problem with gethostbyaddr with intranet addresses on MAC

Sion Arrowsmith siona at chiark.greenend.org.uk
Mon Jan 28 13:02:53 EST 2008


shailesh  <shaileshk at gmail.com> wrote:
>Python 2.4.4 (#1, Oct 18 2006, 10:34:39)
>[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
>Type "help", "copyright", "credits" or "license" for more information.
>>>> from socket import *
>>>> x = gethostbyname('google.com')
>>>> x
>'64.233.167.99'
>>>> gethostbyaddr(x)
>('py-in-f99.google.com', [], ['64.233.167.99'])
>>>> e = '192.168.4.123'
>>>> gethostbyaddr(e)
>Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
>socket.herror: (1, 'Unknown host')
>>>>

So what are you expecting it to return? Or, to put it another way,
what would you feed to gethostbyname() to get 192.168.4.123 back?
Can you get the "right" answer from host or some other command-
line tool? Can you get an answer from gethostbyaddr() on one of
the other machines on the network? How do they do their name
resolution?

-- 
\S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
   "Frankly I have no feelings towards penguins one way or the other"
        -- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump



More information about the Python-list mailing list