Skip to content

Instantly share code, notes, and snippets.

@bmizerany
Forked from adamwiggins/sorted_ips.rb
Created October 10, 2008 01:59
Show Gist options
  • Save bmizerany/15962 to your computer and use it in GitHub Desktop.
Save bmizerany/15962 to your computer and use it in GitHub Desktop.
require 'resolv'
def ips_for(host)
Resolv::DNS.open do |dns|
ress = dns.getresources(host, Resolv::DNS::Resource::IN::A)
ress.map { |r| r.address.to_s }
end
end
puts ips_for('heroku.com').sort.first
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment