Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Finding all CNAMEs associated with an A record

502 views
Skip to first unread message

Anshuman Kanwar

unread,
Nov 17, 2003, 3:27:04 PM11/17/03
to
Hi all,

Given that I created a many to one relation between CNAMEs records and an A
record, is there a way to get a list of all CNAMEs by querying the A name ?

example :

bird IN A 192.168.0.5
chicken IN CNAME bird
hen IN CNAME bird
rooster IN CNAME bird

Now I want run some commad, which gives me :

# some-command bird
chicken
hen
rooster


Thanks much,
-ansh


Barry Margolin

unread,
Nov 17, 2003, 6:31:14 PM11/17/03
to
In article <bpblh7$2s3o$1...@sf1.isc.org>,

Anshuman Kanwar <an...@expertcity.com> wrote:
>Hi all,
>
>Given that I created a many to one relation between CNAMEs records and an A
>record, is there a way to get a list of all CNAMEs by querying the A name ?

No. I could create a CNAME record on my server:

mycname.mydomain.com. IN CNAME bird.yourdomain.com.

and the server for yourdomain.com has no way of knowing about it.

If you're only interested in finding the CNAME records in your own domain,
you could do something like:

dig yourdomain.com axfr | grep 'CNAME<tab>bird$'

--
Barry Margolin, barry.m...@level3.com
Level(3), Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

Kevin Darcy

unread,
Nov 17, 2003, 6:51:08 PM11/17/03
to
Anshuman Kanwar wrote:

>Hi all,
>
>Given that I created a many to one relation between CNAMEs records and an A
>record, is there a way to get a list of all CNAMEs by querying the A name ?
>

>example :
>
>bird IN A 192.168.0.5
>chicken IN CNAME bird
>hen IN CNAME bird
>rooster IN CNAME bird
>
>Now I want run some commad, which gives me :
>
># some-command bird
>chicken
>hen
>rooster
>

As long as you're limiting yourself to CNAMEs that are in a particular
zone, then this should be a fairly easy Perl script to write. Basic
structure: do a zone transfer of the specified zone, looking for CNAME
records with the specified name in their RDATA. Quick-and-dirty:

#!/usr/bin/perl

use Net::DNS;

($target, $zone) = @ARGV;

$res = new Net::DNS::Resolver;
foreach $rr ($res->axfr($zone)) {
print $rr->name."\n" if (($rr->type eq "CNAME") && ($rr->rdatastr eq
$target."."));
}

But, of course, CNAMEs in one zone can point to a name in a completely
different zone. Without downloading every zone in existence, there's no
way to know for sure whether one of them might contain a CNAME reference
to any given name.


- Kevin


Pete Ehlke

unread,
Nov 17, 2003, 7:04:42 PM11/17/03
to
On Mon, Nov 17, 2003 at 12:27:04PM -0800, Anshuman Kanwar wrote:
>
> Given that I created a many to one relation between CNAMEs records and an A
> record, is there a way to get a list of all CNAMEs by querying the A name ?
>
No.

Mark_A...@isc.org

unread,
Nov 17, 2003, 7:41:52 PM11/17/03
to

> Hi all,

>
> Given that I created a many to one relation between CNAMEs records and an A
> record, is there a way to get a list of all CNAMEs by querying the A name ?

No.


> example :
>
> bird IN A 192.168.0.5
> chicken IN CNAME bird
> hen IN CNAME bird
> rooster IN CNAME bird
>
> Now I want run some commad, which gives me :
>
> # some-command bird
> chicken
> hen
> rooster
>
>

> Thanks much,
> -ansh
--
Mark Andrews, Internet Software Consortium
1 Seymour St., Dundas Valley, NSW 2117, Australia
PHONE: +61 2 9871 4742 INTERNET: Mark.A...@isc.org

0 new messages