-
-
Save abhishek77in/ab282543afa13605aac99e4ead26551c 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 = '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