require 'resolv'
dns = Resolv::DNS.new
domain = "oreilly.com"
dns.each_resource(domain, Resolv::DNS::Resource::IN::MX) do |mail_server|
puts mail_server.exchange
end
# smtp1.oreilly.com
# smtp2.oreilly.com
==
Get name server
require 'resolv'
dns = Resolv::DNS.new
dns.each_resource(domain, Resolv::DNS::Resource::IN::NS) do |nameserver|
puts nameserver.name
end
# a.auth-ns.sonic.net
# b.auth-ns.sonic.net
# c.auth-ns.sonic.net
# ns.oreilly.com