Skip to content

Instantly share code, notes, and snippets.

@silviupanaite
Forked from Maysora/cname_check.rb
Created December 11, 2019 12:42
Show Gist options
  • Save silviupanaite/cfbfcf23c558bfddcfe79079bbe64110 to your computer and use it in GitHub Desktop.
Save silviupanaite/cfbfcf23c558bfddcfe79079bbe64110 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