Created
December 5, 2016 09:06
-
-
Save Maysora/73f623f851e98abacada42388f365c41 to your computer and use it in GitHub Desktop.
Ruby DNS CNAME check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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