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
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.
>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
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