Get all the addresses associated with a hostname : IP Address « Network « Ruby






Get all the addresses associated with a hostname

require 'resolv'

Resolv.each_address("http://www.google.com/") do |ip|
  puts ip
end

 








Related examples in the same category

1.resolv useful for converting between hostnames and IP addresses
2.turn IP addresses into hostnames using the getname method
3.To search for MX records you have to use the Resolv::DNS class