How to reverse lookup an IP address using Async::DNS::Resolver
?
#26
Answered
by
adam12
postmodern
asked this question in
Q&A
-
How do I do a reverse lookup of an IP using resolver = Async::DNS::Resolver.new([[:udp, '8.8.8.8', 53]])
Async { p resolver.query('1.1.1.1', Resolv::DNS::Resource::IN::PTR) }
# #<Resolv::DNS::Message:0x00007f8a68a07400 @id=64041, @qr=1, @opcode=0, @aa=0, @tc=0, @rd=1, @ra=1, @rcode=3, @question=[[#<Resolv::DNS::Name: 1.1.1.1.>, Resolv::DNS::Resource::IN::PTR]], @answer=[], @authority=[[#<Resolv::DNS::Name: .>, 86375, #<Resolv::DNS::Resource::IN::SOA:0x00007f8a68a091d8 @mname=#<Resolv::DNS::Name: a.root-servers.net.>, @rname=#<Resolv::DNS::Name: nstld.verisign-grs.com.>, @serial=2023040502, @refresh=1800, @retry=900, @expire=604800, @minimum=86400, @ttl=86375>]], @additional=[]> Reverse looking up |
Beta Was this translation helpful? Give feedback.
Answered by
adam12
Feb 14, 2024
Replies: 1 comment 1 reply
-
Need to query the 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 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
postmodern
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Need to query the
in-addr.arpa
zone.