class Resolv
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(&: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.
Public Class Methods
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/resolv/0/resolv.rbs, line 35
def self.each_address: (String name) { (String) -> void } -> void
Iterates over all IP addresses for name.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/resolv/0/resolv.rbs, line 43
def self.each_name: (String address) { (String) -> void } -> void
Iterates over all hostnames for address.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/resolv/0/resolv.rbs, line 51
def self.getaddress: (String name) -> String
Looks up the first IP address for name.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/resolv/0/resolv.rbs, line 59
def self.getaddresses: (String name) -> Array[String]
Looks up all IP address for name.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/resolv/0/resolv.rbs, line 67
def self.getname: (String address) -> String
Looks up the hostname of address.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/resolv/0/resolv.rbs, line 75
def self.getnames: (String address) -> Array[String]
Looks up all hostnames for address.
(?Resolv::Hosts | Resolv::DNS resolvers) → untyped
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/resolv/0/resolv.rbs, line 137
def initialize: (?Resolv::Hosts | Resolv::DNS resolvers) -> untyped
Public Instance Methods
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/resolv/0/resolv.rbs, line 83
def each_address: (String name) { (String) -> void } -> void
Iterates over all IP addresses for name.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/resolv/0/resolv.rbs, line 91
def each_name: (String name) { (String) -> void } -> void
Iterates over all hostnames for address.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/resolv/0/resolv.rbs, line 99
def getaddress: (String name) -> String
Looks up the first IP address for name.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/resolv/0/resolv.rbs, line 107
def getaddresses: (String name) -> Array[String]
Looks up all IP address for name.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/resolv/0/resolv.rbs, line 115
def getname: (String address) -> String
Looks up the hostname of address.