How to get easily (from a script) all CNAME of a A record?
Philippe.Simonet at swisscom.com
Philippe.Simonet at swisscom.com
Tue Nov 9 21:16:08 UTC 2010
Hi
If you have control over all zones, you could also pre-store the results of
your search in DNS :)
For all CNAME records, make e.g. a TXT record with the reverse result :
(TXT is maybe not the better record type...which ones (for specialists))
For each :
a-name IN A 1.2.3.4
an-alias IN CNAME a-name
Just add :
a-name IN TXT an-alias
and make more than one TXT records for each cname pointing to the same record ...
a-name IN TXT another-alias
best regards
Philippe
From: bind-users-bounces+philippe.simonet=swisscom.com at lists.isc.org [mailto:bind-users-bounces+philippe.simonet=swisscom.com at lists.isc.org] On Behalf Of Stacey Jonathan Marshall
Sent: mardi 9 novembre 2010 16:53
To: bind-users at lists.isc.org
Subject: Re: How to get easily (from a script) all CNAME of a A record?
On 09/11/2010 14:14, Michelle Konzack 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
------------------------------------------------------------------------
...and it is to slow do to more then 80.000 Zones (they have to be
greped all) number of VHosts.
Oh, it is now time to use "xargs", because I saw today, that I hit the
limits for "ls". :-D
Following is working:
cd /etc/bind && ls
but not:
cd /etc/bind && ls *
or
cd /etc/bind && ls *.signed
and the OSes are called Linux and BSD... WTF?
It seems that a commandline can not have more then 31.000 characters.
(no not options but total lenght)
Thanks, Greetings and nice Day/Evening
Michelle Konzack
The asterisk causes the shell to expand the names and run ls with them as a single command, so in effect you have "ls file1 file2 file3 ...". Try the following instead:
cd /etc/bind
for FILE in *.signed
do
grep --regexp=" IN CNAME .*${QUERY}" ${FILE} 2>/dev/null |cut -d ' ' -f1 |sed 's|.$||'
done
It might still have the same issue, but worth a go.
I assume the command length is also why your not simply running "grep -h <expression> *.signed"?
Stace
_______________________________________________
bind-users mailing list
bind-users at lists.isc.org<mailto:bind-users at lists.isc.org>
https://lists.isc.org/mailman/listinfo/bind-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/bind-users/attachments/20101109/167a1e65/attachment.html>
More information about the bind-users
mailing list