# CNAME lookup with ruby

**URL:** <https://www.ruby-forum.com/t/cname-lookup-with-ruby/175216>\
**Category:** Ruby\
**Created:** [September 9, 2009, 8:23pm UTC](https://www.ruby-forum.com/t/cname-lookup-with-ruby/175216 "2009-09-09T20:23:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hypnos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/8797f3/32.png) [@hypnos](https://www.ruby-forum.com/u/hypnos)\
**Post date:** [September 9, 2009, 8:23pm UTC](https://www.ruby-forum.com/t/cname-lookup-with-ruby/175216/1 "2009-09-09T20:23:29Z")

</div>

Hi,

I want to be able to use ruby to look up a particular CNAME domain and  
see where it is pointing to, is there a way to do this with the ruby DNS  
lookup libraries?

To clarify I have an application where each user has a subdomain like  
[user.example.com](http://user.example.com) and I want the user to be able to set up a CNAME record  
to this subdomain.

Then I want to use some middleware to be able detect that the  
application is being accessed from a custom domain, then lookup where  
the custom domain is pointed to, e.g. [user.example.com](http://user.example.com), and then change  
the request to this address so the whole thing is hidden from my app.

Any help or suggestions are very welcome!

---

<div class="post-metadata">

**Author:** ![hypnos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/8797f3/32.png) [@hypnos](https://www.ruby-forum.com/u/hypnos)\
**Post date:** [September 10, 2009, 9:32am UTC](https://www.ruby-forum.com/t/cname-lookup-with-ruby/175216/2 "2009-09-10T09:32:39Z")

</div>

On Sep 9, 2009, at 11:23, Oliver Nightingale wrote:

> I want to be able to use ruby to look up a particular CNAME domain and  
> see where it is pointing to, is there a way to do this with the ruby  
> DNS  
> lookup libraries?

look at Resolv, it allows you to perform arbitrary DNS lookups.
