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?

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.