Skip to content

Instantly share code, notes, and snippets.

@leighmcculloch
Created August 20, 2014 18:22
Show Gist options
  • Save leighmcculloch/48485350c76b2566e410 to your computer and use it in GitHub Desktop.
Save leighmcculloch/48485350c76b2566e410 to your computer and use it in GitHub Desktop.
Multi-Region DNS Lookup Utility
# Multi-Region DNS NameServer Propogation Check
#
# Uses the dns-lg.com API to retrieve the NS records for a zone (domain name)
# at 19 (more or less) different locations globally. Use this to monitor the
# propogation of nameserver changes at your registrar.
#
# Note: There is no such thing as a guarantee when it comes to whether your
# new nameservers have propogated fully or not. Rule of thumb is three days
# but often it is much faster and this check can help you weigh the risks.
require 'net/http'
require 'json'
if ARGV.length != 1
puts "Usage: ruby mdig.rb [domain name]"
puts "Example: ruby mdig.rb example.com"
exit
end
nodes = JSON.parse(Net::HTTP.get("www.dns-lg.com", "/nodes.json"))["nodes"]
nodes.each do |node|
puts "#{node["country"]} – #{node["name"]}"
response = JSON.parse(Net::HTTP.get("www.dns-lg.com", "/#{node["name"]}/#{ARGV[0]}/ns"))
records = response["answer"]
records.each do |record|
puts " #{record["ttl"]} #{record["type"]} #{record["rdata"]}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment