Skip to content

Instantly share code, notes, and snippets.

@abhishek77in
Forked from Maysora/cname_check.rb
Last active September 23, 2022 18:04
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 abhishek77in/ab282543afa13605aac99e4ead26551c to your computer and use it in GitHub Desktop.
Save abhishek77in/ab282543afa13605aac99e4ead26551c to your computer and use it in GitHub Desktop.
Ruby DNS CNAME check
require 'resolv'
url = 'www.diagnofy.in'
begin
r = Resolv::DNS.open do |dns|
dns.timeouts = 1
dns.getresource(url, Resolv::DNS::Resource::IN::CNAME)
end
r.name.to_s # => return alias domain
rescue Resolv::ResolvError => e
# handle error
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment