get host by addr

  • Thread starter Nikos Kanellopoulos
  • Start date
N

Nikos Kanellopoulos

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
 
N

Nikos Kanellopoulos

2007/8/12 said:
-----Original Message-----
From: Nikos Kanellopoulos [mailto:[email protected]]
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...
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top