RubyDNS Documentation

  1. Installation
  2. Basic DNS Server
  3. Asynchronous DNS Resolution
  4. DNS Verification
  5. DNS Testing
  6. API Documentation

RubyDNS can be used as an asynchronous DNS client, either passing requests to a specific server or using default system resolvers.

# There technically should be at least one nameserver:
resolver =

EventMachine::run do
	resolver.query('') do |response|
		assert_equal RubyDNS::Message, response.class
		assert_equal Resolv::DNS::RCode::NoError, response.rcode


EventMachine provides the basic asynchronous event processing loop, and thus any use of RubyDNS::Resolver must happen within a valid EventMachine context.


As this is an asynchronous service, a timeout can be provided (the default is 5 seconds). If a response is not received within a given time, a RubyDNS::ResolutionFailure error will be returned to the caller in the response argument:

SERVERS = [[:udp, '', 5330], [:tcp, '', 5330]]
resolver =, :timeout => 60)

For more examples, please check out rubydns/test/test_slow_server.rb.


Additional debugging output can be sent to a log file by providing the :logger option:

require 'logger'

SERVERS = [[:udp, '', 5330], [:tcp, '', 5330]]
resolver =, :logger =>$stderr))