How to get easily (from a script) all CNAME of a A record?

Barry Margolin barmar at alum.mit.edu
Wed Nov 10 05:13:27 UTC 2010


In article <mailman.667.1289312062.555.bind-users at lists.isc.org>,
 Michelle Konzack <linux4michelle at tamay-dogan.net> wrote:

> Hello Matus UHLAR - fantomas,
> 
> Am 2010-11-09 14:13:47, hacktest Du folgendes herunter:
> > I am not sure whether dnswalk over whole internet can do that, but on your
> 
> I will try it...
> 
> > server you can either run recursive grep over named data directory, or dump
> > the named dsatabase and grep it...
> 
> This is what I currently do...
> 
> ----[ '/usr/sbin/get_hosts_in cname' ]----------------------------------
> #!/bin/sh
> 
> QUERY="$1"
> 
> for FILE in $(cd /etc/bind && ls *.signed)
> do
>   grep --regexp=" IN CNAME .*${QUERY}" /etc/bind/${FILE} 2>/dev/null |cut -d 
>   ' ' -f1 |sed 's|.$||'
> done
> ------------------------------------------------------------------------

It would probably be faster if you didn't start a new grep process for 
each file.  Try:

find /etc/bind -name '*.signed' | xargs sed -n "/ IN CNAME .*$QUERY/s/\. 
.*$//p"

-- 
Barry Margolin, barmar at alum.mit.edu
Arlington, MA
*** PLEASE don't copy me on replies, I'll read them in the group ***



More information about the bind-users mailing list