class method
Resolv::DNS.new
(?::String | ::Hash[::Symbol, untyped] config_info) -> ::Resolv::DNS
new(config_info=nil)
lib/resolv.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/resolv.rb, line 338
def initialize(config_info=nil)
@mutex = Thread::Mutex.new
@config = Config.new(config_info)
@initialized = nil
end
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. :raise_timeout_errors can be used to raise timeout errors as exceptions instead of treating the same as an NXDOMAIN response.
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:
Example
Resolv::DNS.new(:nameserver => ['210.251.121.21'], :search => ['ruby-lang.org'], :ndots => 1)