problem with gethostbyaddr with intranet addresses on MAC

Discussion in 'Python' started by shailesh, Jan 25, 2008.

  1. shailesh

    shailesh Guest

    Hi,

    I am facing a peculiar problem. socket.gethostbyaddr is not working
    fine on my MAC for ip addresses on the LAN. The LAN happens to consist
    of linux and windows machines and this is the only one MAC on the
    LAN.

    Please see the example below. I am getting error: socket.herror: (1,
    'Unknown host')



    apples-computer:~ apple$ ping 192.168.4.123
    PING 192.168.4.123 (192.168.4.123): 56 data bytes
    64 bytes from 192.168.4.123: icmp_seq=0 ttl=64 time=0.328 ms
    64 bytes from 192.168.4.123: icmp_seq=1 ttl=64 time=0.236 ms
    64 bytes from 192.168.4.123: icmp_seq=2 ttl=64 time=0.255 ms
    ^C
    --- 192.168.4.123 ping statistics ---
    3 packets transmitted, 3 packets received, 0% packet loss
    round-trip min/avg/max/stddev = 0.236/0.273/0.328/0.040 ms
    apples-computer:~ apple$ python2.4
    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')
    >>>



    With regards,
    - Shailesh
     
    shailesh, Jan 25, 2008
    #1
    1. Advertisements

  2. shailesh <> 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 -- -- 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
     
    Sion Arrowsmith, Jan 28, 2008
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Neil Aggarwal

    gethostbyaddr returning null for CNAME records

    Neil Aggarwal, Feb 25, 2004, in forum: C Programming
    Replies:
    2
    Views:
    4,045
    Ben Pfaff
    Feb 25, 2004
  2. Mohammed Smadi

    socket.gethostbyaddr problem

    Mohammed Smadi, Sep 18, 2005, in forum: Python
    Replies:
    1
    Views:
    704
    Irmen de Jong
    Sep 18, 2005
  3. Harlin Seritt

    socket.gethostbyaddr() question

    Harlin Seritt, Jan 15, 2006, in forum: Python
    Replies:
    2
    Views:
    2,319
    Steve Holden
    Jan 15, 2006
  4. gethostbyaddr/nslookup failed

    , Jul 27, 2005, in forum: C Programming
    Replies:
    1
    Views:
    690
    Artie Gold
    Jul 27, 2005
  5. namespace1
    Replies:
    3
    Views:
    1,102
  6. Skijor

    JMX/getHostByAddr

    Skijor, Sep 19, 2010, in forum: Java
    Replies:
    0
    Views:
    519
    Skijor
    Sep 19, 2010
  7. cjblaine
    Replies:
    1
    Views:
    469
    Ned Deily
    Apr 28, 2011
  8. Replies:
    3
    Views:
    227
    Peter J. Holzer
    Mar 17, 2007
Loading...