Skip to content

Instantly share code, notes, and snippets.

@Maysora
Created December 5, 2016 09:06
Show Gist options
  • Save Maysora/73f623f851e98abacada42388f365c41 to your computer and use it in GitHub Desktop.
Save Maysora/73f623f851e98abacada42388f365c41 to your computer and use it in GitHub Desktop.
Ruby DNS CNAME check
require 'resolv'
url = 'mail.bocistudio.com'
begin
r = Resolv::DNS.open do |dns|
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