Class

Resolv::DNS is a DNS stub resolver.

Information taken from the following places:

Constants

Default DNS Port

Default DNS UDP packet size

No documentation available
No documentation available
Class Methods

Creates a new DNS resolver.

config_info can be:

nil

Uses /etc/resolv.conf.

String

Path to a file using /etc/resolv.conf’s format.

Hash

Must contain :nameserver, :search and :ndots keys.

:nameserver_port can be used to specify port number of nameserver address.

The value of :nameserver should be an address string or an array of address strings.

  • :nameserver => ‘8.8.8.8’

  • :nameserver => [‘8.8.8.8’, ‘8.8.4.4’]

The value of :nameserver_port should be an array of pair of nameserver address and port number.

  • :nameserver_port => [[‘8.8.8.8’, 53], [‘8.8.4.4’, 53]]

Example:

Resolv::DNS.new(:nameserver => ['210.251.121.21'],
                :search => ['ruby-lang.org'],
                :ndots => 1)

Creates a new DNS resolver. See Resolv::DNS.new for argument details.

Yields the created DNS resolver to the block, if given, otherwise returns it.

Instance Methods

Closes the DNS resolver.

Iterates over all IP addresses for name retrieved from the DNS resolver.

name can be a Resolv::DNS::Name or a String. Retrieved addresses will be a Resolv::IPv4 or Resolv::IPv6

Iterates over all hostnames for address retrieved from the DNS resolver.

address must be a Resolv::IPv4, Resolv::IPv6 or a String. Retrieved names will be Resolv::DNS::Name instances.

Iterates over all typeclass DNS resources for name. See getresource for argument details.

No documentation available

Gets the IP address of name from the DNS resolver.

name can be a Resolv::DNS::Name or a String. Retrieved address will be a Resolv::IPv4 or Resolv::IPv6

Gets all IP addresses for name from the DNS resolver.

name can be a Resolv::DNS::Name or a String. Retrieved addresses will be a Resolv::IPv4 or Resolv::IPv6

Gets the hostname for address from the DNS resolver.

address must be a Resolv::IPv4, Resolv::IPv6 or a String. Retrieved name will be a Resolv::DNS::Name.

Gets all hostnames for address from the DNS resolver.

address must be a Resolv::IPv4, Resolv::IPv6 or a String. Retrieved names will be Resolv::DNS::Name instances.

Look up the typeclass DNS resource of name.

name must be a Resolv::DNS::Name or a String.

typeclass should be one of the following:

Returned resource is represented as a Resolv::DNS::Resource instance, i.e. Resolv::DNS::Resource::IN::A.

Looks up all typeclass DNS resources for name. See getresource for argument details.

Sets the resolver timeouts. This may be a single positive number or an array of positive numbers representing timeouts in seconds. If an array is specified, a DNS request will retry and wait for each successive interval in the array until a successful response is received. Specifying nil reverts to the default timeouts:

5, second = 5 * 2 / nameserver_count, 2 * second, 4 * second

Example:

dns.timeouts = 3