Skip to content

Instantly share code, notes, and snippets.

@darron
Created February 27, 2010 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darron/316856 to your computer and use it in GitHub Desktop.
Save darron/316856 to your computer and use it in GitHub Desktop.
require 'rubygems'
# sudo gem install whois # http://www.ruby-whois.org/
require 'whois'
# From your named configuration files:
# egrep -r zone * | cut -d ' ' -f 2 | cut -d '"' -f 2 | sort | uniq > domains.txt
File.open("domains.txt", "r") do |infile|
while (line = infile.gets)
puts "Domain: #{line}"
begin
a = Whois.whois("#{line}")
rescue
puts "Timeout."
end
# Some whois servers don't support nameserver query.
# most notably .ca domains.
begin
a.nameservers.each do |nameserver|
puts nameserver
end
rescue
whois_data = `/usr/bin/whois #{line}`
puts whois_data
end
puts ""
# Sleep lots otherwise people start to block us.
sleep 5
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment