Skip to content

How to reverse lookup an IP address using Async::DNS::Resolver? #26

Answered by adam12
postmodern asked this question in Q&A
Discussion options

You must be logged in to vote

Need to query the in-addr.arpa zone.

resolver = Async::DNS::Resolver.new([[:udp, "8.8.8.8", 53], [:tcp, "8.8.8.8", 53]])

Async do
  message = resolver.query("1.1.1.1.in-addr.arpa", Resolv::DNS::Resource::IN::PTR)
  _name, _ttl_, record = message.answer.first
  p record.name
end

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@adam12
Comment options

Answer selected by postmodern
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants