# Using resolv.rb

**URL:** <https://rubytalk.org/t/using-resolv-rb/38716>\
**Category:** ruby-talk\
**Created:** [28 June 2007 22:25 UTC](https://rubytalk.org/t/using-resolv-rb/38716 "2007-06-28T22:25:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_B](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@Mike\_B](https://rubytalk.org/u/Mike_B)\
**Post date:** [28 June 2007 22:25 UTC](https://rubytalk.org/t/using-resolv-rb/38716/1 "2007-06-28T22:25:03Z")

</div>

Can someone point me to some documentation that shows me with examples  
how to use that ruby library?

I was just trying to point the resolver at a specific DNS server, but  
had trouble figuring out how to do it.

I found the Resolv documentation, but non of the examples showed how  
to change what dns server the resolver library used to resolve the  
names.

Thanks for any pointers.

Mike B.

---

<div class="post-metadata">

**Author:** ![Adam\_Bozanich](https://avatars.discourse-cdn.com/v4/letter/a/90db22/32.png) [@Adam\_Bozanich](https://rubytalk.org/u/Adam_Bozanich)\
**Post date:** [29 June 2007 00:13 UTC](https://rubytalk.org/t/using-resolv-rb/38716/2 "2007-06-29T00:13:43Z")

</div>

Looks like the source code has some stuff that didn't make it to the  
documentation:

== Resolv::DNS classDNS stub resolver.=== class methods---  
Resolv::DNS.new(config\_info=nil)  
((|config\_info|)) should be nil, a string or a hash. If nil is given,  
/etc/resolv.conf and platform specific information is used. If a string  
is given, it should be a filename which format is same as  
/etc/resolv.conf. If a hash is given, it may contains information for  
nameserver, search and ndots as follows. Resolv::DNS.new  
({:nameserver=\>["210.251.121.21"], :search=\>["ruby-lang.org"], :ndots=\>1})

--- Resolv::DNS.open(config\_info=nil)  
--- Resolv::DNS.open(config\_info=nil) {|dns| ...}

Example ( verified ):

require 'resolv'  
Resolv::DNS.open({:nameserver=\>["206.13.28.12"]}) do |r|  
&nbsp;&nbsp;&nbsp;&nbsp;puts r.getaddress("www.google.com")  
end

-Adam

> **···**
>
> On 6/28/07, barjunk \<barjunk@attglobal.net\> wrote:
> 
> > Can someone point me to some documentation that shows me with examples  
> > how to use that ruby library?
> > 
> > I was just trying to point the resolver at a specific DNS server, but  
> > had trouble figuring out how to do it.
> > 
> > I found the Resolv documentation, but non of the examples showed how  
> > to change what dns server the resolver library used to resolve the  
> > names.

---

<div class="post-metadata">

**Author:** ![Vinay\_Beckham](https://avatars.discourse-cdn.com/v4/letter/v/47e85d/32.png) [@Vinay\_Beckham](https://rubytalk.org/u/Vinay_Beckham)\
**Post date:** [29 August 2007 11:25 UTC](https://rubytalk.org/t/using-resolv-rb/38716/3 "2007-08-29T11:25:00Z")

</div>

Adam Bozanich wrote:

> **···**
>
> > On 6/28/07, barjunk \<barjunk@attglobal.net\> wrote:
> > 
> > Example ( verified ):
> > 
> > require 'resolv'  
> > Resolv::DNS.open({:nameserver=\>["206.13.28.12"]}) do |r|  
> > &nbsp;&nbsp;&nbsp;&nbsp;puts r.getaddress("www.google.com")  
> > end
> > 
> > -Adam
> 
> Hi Adam...  
> :nameserver=\>["206.13.28.12"]  
> here the nameserver can have any LIVE IP right?? i mean i tried changing  
> this IP and used one of my own server IPs.. and it worked the same...  
> please correct me if I am going wrong ....  
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
