Ruby/Network/DNS
Материал из Wiki.crossplatform.ru
Get email server
require "resolv" dns = Resolv::DNS.new domain = "oreilly.ru" dns.each_resource(domain, Resolv::DNS::Resource::IN::MX) do |mail_server| puts mail_server.exchange end # smtp1.oreilly.ru # smtp2.oreilly.ru == 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.ru
Performing DNS Queries
require "resolv" Resolv::DNS.new.each_address("oreilly.ru") { |addr| puts addr }