turn IP addresses into hostnames using the getname method : IP Address « Network « Ruby






turn IP addresses into hostnames using the getname method



require 'resolv'

ip = "192.0.34.166"

begin
  puts Resolv.getname(ip)
rescue
  puts "No hostname associated with #{ip}"
end

 








Related examples in the same category

1.resolv useful for converting between hostnames and IP addresses
2.Get all the addresses associated with a hostname
3.To search for MX records you have to use the Resolv::DNS class