Class

Resolv::DNS

Inheritance
< Object

Resolv::DNS is a DNS stub resolver.

Information taken from the following places:

Classes & Modules

Constants

Name   Description
DNSThreadGroup = ThreadGroup.new Group of DNS resolver threads
Port = 53 Default DNS Port
UDPSize = 512 Default DNS UDP packet size

Methods

Class

Visibility Signature
public new (config_info=nil)
public open (*args) {|dns| ...}

Instance

Visibility Signature
public close ()
public each_address (name) {|resource.address| ...}
public each_name (address) {|resource.name| ...}
public each_resource (name, typeclass, &proc)
public getaddress (name)
public getaddresses (name)
public getname (address)
public getnames (address)
public getresource (name, typeclass)
public getresources (name, typeclass)

Class Method Detail

new(config_info=nil)

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.

Example:

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

open(*args) {|dns| ...}

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 Method Detail

close()

Closes the DNS resolver.

each_address(name) {|resource.address| ...}

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

each_name(address) {|resource.name| ...}

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.

each_resource(name, typeclass, &proc)

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

getaddress(name)

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

getaddresses(name)

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

getname(address)

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.

getnames(address)

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.

getresource(name, typeclass)

getresources(name, typeclass)

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