Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resolve domain from IP address using Ruby

Tags:

ruby

ip

dns

I have requirements to find domain name using IP address using Ruby.

I have some IP addresses. I got every time different random IP address. But I have to filter the IP addresses that have a domain name.

How to find the domain name?

like image 847
user1780370 Avatar asked Dec 19 '22 07:12

user1780370


1 Answers

You can use the stdlib Resolve.

Resolv is a thread-aware DNS resolver library written in Ruby. Resolv can handle multiple DNS requests concurrently without blocking the entire Ruby interpreter.

Resolv can look up various DNS resources using the DNS module directly.

require 'resolv'
Resolv.getname "210.251.121.214" # => "ci.ruby-lang.org"
like image 133
Arup Rakshit Avatar answered Dec 27 '22 04:12

Arup Rakshit