Resolve hostname from IP

Hi. I’ve read about using request.remote_ip to resolve an IP from an
incoming request. Is there a similar way to resolve the hostname from an
incoming request or do I need to use the IP in combination with some
other library?

Best regards and many thanks,
gustav

You’d need to use another library.

On Dec 11, 2007 10:34 AM, Gustav S.
[email protected]
wrote:


Ryan B.
http://www.frozenplague.net

Ryan B. wrote:

You’d need to use another library.

Ok. You think the Ruby Socket-library will do?

That’s something I didn’t know. Interesting to know this, thanks!

On Dec 11, 2007 1:16 PM, Philip H. [email protected] wrote:

=> “bravo.pjkh.com

It’s going to slow your site down however… DNS can take some time… you
may want to cache the data locally or look into having a very close
caching nameserver, etc.


Ryan B.
http://www.frozenplague.net

Hi. I’ve read about using request.remote_ip to resolve an IP from an
incoming request. Is there a similar way to resolve the hostname from an
incoming request or do I need to use the IP in combination with some
other library?

irb(main):001:0> require ‘resolv’
=> true
irb(main):002:0> Resolv.getname(‘72.36.232.219’)
=> “bravo.pjkh.com

It’s going to slow your site down however… DNS can take some time…
you
may want to cache the data locally or look into having a very close
caching nameserver, etc.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs