get host by addr

Discussion in 'Ruby' started by Nikos Kanellopoulos, Aug 11, 2007.

  1. Hello everybody.
    I am trying to do something simple.
    I have an IP address and need to do a reverse DNS lookup.
    However, I consistently get a "host not found" error.
    I have tried this in at least 2 different machines.

    What am I doing wrong?

    nk@livaditis: ~ $ irb
    irb(main):001:0> require 'socket'
    => true
    irb(main):002:0> Socket.gethostbyaddr("75.126.252.65")
    SocketError: host not found
    from (irb):2:in `gethostbyaddr'
    from (irb):2
    from :0
    Nikos Kanellopoulos, Aug 11, 2007
    #1
    1. Advertising

  2. 2007/8/12, Felix Windt <>:
    > > -----Original Message-----
    > > From: Nikos Kanellopoulos [mailto:]
    > > Sent: Saturday, August 11, 2007 3:00 PM
    > > To: ruby-talk ML
    > > Subject: get host by addr
    > >
    > > Hello everybody.
    > > I am trying to do something simple.
    > > I have an IP address and need to do a reverse DNS lookup.
    > > However, I consistently get a "host not found" error.
    > > I have tried this in at least 2 different machines.
    > >
    > > What am I doing wrong?
    > >
    > > nk@livaditis: ~ $ irb
    > > irb(main):001:0> require 'socket'
    > > => true
    > > irb(main):002:0> Socket.gethostbyaddr("75.126.252.65")
    > > SocketError: host not found
    > > from (irb):2:in `gethostbyaddr'
    > > from (irb):2
    > > from :0
    > >

    >
    >
    > irb(main):001:0> require 'socket'
    > => true
    > irb(main):002:0> Socket.getaddrinfo('75.126.252.65', nil)
    > => [["AF_INET", 0, "75.126.252.65-static.reverse.softlayer.com",
    > "75.126.252.65", 2, 1, 6], ["AF_INET", 0,
    > "75.126.252.65-static.reverse.softlayer.com", "75.126.252.65", 2, 2, 17],
    > ["AF_INET", 0, "75.126.252.65-static.reverse.softlayer.com",
    > "75.126.252.65", 2, 3, 0]]
    > irb(main):003:0>
    >
    >


    Nice! This works fine in irb.
    However, it fails to do the reverse lookup from within my rails application.
    It just returns the IP as the host name. Strange...
    Nikos Kanellopoulos, Aug 11, 2007
    #2
    1. Advertising

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. steve
    Replies:
    3
    Views:
    1,437
    Mike Treseler
    Sep 4, 2003
  2. fpgawizz

    not able to write to addr loc x0

    fpgawizz, Apr 2, 2005, in forum: VHDL
    Replies:
    1
    Views:
    439
    info_
    Apr 2, 2005
  3. Replies:
    2
    Views:
    688
    gene tani
    Dec 14, 2005
  4. =?utf-8?B?5LiA6aaW6K+X?=

    My python can not get addr info

    =?utf-8?B?5LiA6aaW6K+X?=, Apr 16, 2006, in forum: Python
    Replies:
    1
    Views:
    929
    Serge Orlov
    Apr 16, 2006
  5. David Cook

    How to get clientside IP-addr

    David Cook, Aug 7, 2004, in forum: Javascript
    Replies:
    3
    Views:
    106
    Grant Wagner
    Aug 9, 2004
Loading...

Share This Page