Skip to content

Instantly share code, notes, and snippets.

@alevy
Created December 8, 2012 00:36
Show Gist options
  • Save alevy/4237840 to your computer and use it in GitHub Desktop.
Save alevy/4237840 to your computer and use it in GitHub Desktop.
Compare Route53 with Ground Truth DNS
require 'net/dns'
require 'route53'
def go(recs, type)
recs.each do |record|
rslv = Net::DNS::Resolver.start(record.name, type).answer
found = true
rslv.each do |answer|
found &&= record.values.select {|v| v.to_s == answer.value.to_s }.size != 0
end
if !found
puts "#{record.name}:"
puts "\t#{rslv.map(&:value).join("\n\t")}"
puts "\t\tvs"
puts "\t#{record.values.join("\n\t")}"
end
end
end
r53 = Route53::Connection.new(ENV["AWS_ACCESS_KEY_ID"], ENV["AWS_SECRET_KEY"])
cnames = r53.get_zones(ARGV.first).first.get_records("CNAME")
arecs = r53.get_zones(ARGV.first).first.get_records("A")
nsrecs = r53.get_zones(ARGV.first).first.get_records("NS")
mxrecs = r53.get_zones(ARGV.first).first.get_records("MX")
go(nsrecs, Net::DNS::NS)
go(cnames, Net::DNS::CNAME)
go(arecs, Net::DNS::A)
go(mxrecs, Net::DNS::MX)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment