Using Dnsruby, which is great, but how do I do a reverse lookup for the hostname associated with an IP address? Or if not dnsruby, other suggested routes?
Here is what I am working with so far, and I figured that my query would have the resolved name also, but its not apparent to me.
resolver = Resolver.new
query = resolver.query("example.com")
ip = query.answer.first.address.to_s
As for more background, I am basically using this in a monitoring app, and with apps on Amazon EC2, and I’d like to see what the IP we’ve been assigned resolves to. I am hoping I can then use that to further assess potential its location etc.
Socket classcan be used for looking up host name based on address.See this answer for an example.