Type:
Class
Constants:
DefaultResolver : self.new

Default resolver to use for Resolv class methods.

AddressRegex : /(?:#{IPv4::Regex})|(?:#{IPv6::Regex})/

Address Regexp to use for matching IP addresses.

Resolv is a thread-aware DNS resolver library written in Ruby. Resolv can handle multiple DNS requests concurrently without blocking the entire ruby interpreter.

See also resolv-replace.rb to replace the libc resolver with Resolv.

Resolv can look up various DNS resources using the DNS module directly.

Examples:

p Resolv.getaddress "www.ruby-lang.org"
p Resolv.getname "210.251.121.214"

Resolv::DNS.open do |dns|
  ress = dns.getresources "www.ruby-lang.org", Resolv::DNS::Resource::IN::A
  p ress.map { |r| r.address }
  ress = dns.getresources "ruby-lang.org", Resolv::DNS::Resource::IN::MX
  p ress.map { |r| [r.exchange.to_s, r.preference] }
end

Bugs

  • NIS is not supported.

  • /etc/nsswitch.conf is not supported.

getaddresses

getaddresses(name) Class Public methods Looks up all IP address for name

2015-05-05 22:24:37
each_name 2

each_name(address) Instance Public methods Iterates over all hostnames for

2015-05-05 22:48:10
getaddress 2

getaddress(name) Instance Public methods Looks up the first IP address for name

2015-05-05 22:53:50
new

new(resolvers=[Hosts.new, DNS.new]) Class Public methods Creates a new

2015-05-05 22:37:26
each_address 2

each_address(name) Instance Public methods Iterates over all IP addresses for

2015-05-05 22:44:35
each_address

each_address(name, &block) Class Public methods Iterates over all IP addresses

2015-05-05 22:08:47
getnames

getnames(address) Class Public methods Looks up all hostnames for address

2015-05-05 22:35:35
getnames 2

getnames(address) Instance Public methods Looks up all hostnames for address

2015-05-05 23:04:28
getname 2

getname(address) Instance Public methods Looks up the hostname of address

2015-05-05 23:01:39
getaddress

getaddress(name) Class Public methods Looks up the first IP address for name

2015-05-05 22:17:38