- Inheritance
- < Object
Resolv::DNS is a DNS stub resolver.
Information taken from the following places:
- STD0013
- RFC 1035
- ftp.isi.edu/in-notes/iana/assignments/dns-parameters
- etc.
Classes & Modules
- Resolv::DNS::DecodeError
- Resolv::DNS::EncodeError
- Resolv::DNS::Name
- Resolv::DNS::Query
- Resolv::DNS::Resource
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)
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)
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:
- Resolv::DNS::Resource::IN::A
- Resolv::DNS::Resource::IN::AAAA
- Resolv::DNS::Resource::IN::ANY
- Resolv::DNS::Resource::IN::CNAME
- Resolv::DNS::Resource::IN::HINFO
- Resolv::DNS::Resource::IN::MINFO
- Resolv::DNS::Resource::IN::MX
- Resolv::DNS::Resource::IN::NS
- Resolv::DNS::Resource::IN::PTR
- Resolv::DNS::Resource::IN::SOA
- Resolv::DNS::Resource::IN::TXT
- Resolv::DNS::Resource::IN::WKS
Returned resource is represented as a Resolv::DNS::Resource instance, i.e. Resolv::DNS::Resource::IN::A.
getresources(name, typeclass)
Looks up all typeclass DNS resources for name. See getresource for argument details.