<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";
color:black;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";
color:black;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;
color:black;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body bgcolor=white lang=FR-CH link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hi<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>If you have control over all zones, you could also pre-store the results of <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>your search in DNS </span><span lang=EN-US style='font-size:11.0pt;font-family:Wingdings;color:#1F497D'>J</span><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>For all CNAME records, make e.g. a TXT record with the reverse result : <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>(TXT is maybe not the better record type…which ones (for specialists))<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>For each : <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>a-name IN A 1.2.3.4<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>an-alias IN CNAME a-name<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Just add : <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>a-name IN TXT an-alias<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>and make more than one TXT records for each cname pointing to the same record …<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>a-name IN TXT another-alias<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>best regards<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Philippe<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div style='border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt'><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'> bind-users-bounces+philippe.simonet=swisscom.com@lists.isc.org [mailto:bind-users-bounces+philippe.simonet=swisscom.com@lists.isc.org] <b>On Behalf Of </b>Stacey Jonathan Marshall<br><b>Sent:</b> mardi 9 novembre 2010 16:53<br><b>To:</b> bind-users@lists.isc.org<br><b>Subject:</b> Re: How to get easily (from a script) all CNAME of a A record?<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>On 09/11/2010 14:14, Michelle Konzack wrote: <o:p></o:p></p><pre>Hello Matus UHLAR - fantomas,<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>Am 2010-11-09 14:13:47, hacktest Du folgendes herunter:<o:p></o:p></pre><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>I am not sure whether dnswalk over whole internet can do that, but on your<o:p></o:p></pre></blockquote><pre><o:p> </o:p></pre><pre>I will try it...<o:p></o:p></pre><pre><o:p> </o:p></pre><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>server you can either run recursive grep over named data directory, or dump<o:p></o:p></pre><pre>the named dsatabase and grep it...<o:p></o:p></pre></blockquote><pre><o:p> </o:p></pre><pre>This is what I currently do...<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>----[ '/usr/sbin/get_hosts_in cname' ]----------------------------------<o:p></o:p></pre><pre>#!/bin/sh<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>QUERY="$1"<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>for FILE in $(cd /etc/bind && ls *.signed)<o:p></o:p></pre><pre>do<o:p></o:p></pre><pre> grep --regexp=" IN CNAME .*${QUERY}" /etc/bind/${FILE} 2>/dev/null |cut -d ' ' -f1 |sed 's|.$||'<o:p></o:p></pre><pre>done<o:p></o:p></pre><pre>------------------------------------------------------------------------<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>...and it is to slow do to more then 80.000 Zones (they have to be<o:p></o:p></pre><pre>greped all) number of VHosts.<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>Oh, it is now time to use "xargs", because I saw today, that I hit the<o:p></o:p></pre><pre>limits for "ls". :-D<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>Following is working:<o:p></o:p></pre><pre> cd /etc/bind && ls<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>but not:<o:p></o:p></pre><pre> cd /etc/bind && ls *<o:p></o:p></pre><pre>or<o:p></o:p></pre><pre> cd /etc/bind && ls *.signed<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>and the OSes are called Linux and BSD... WTF?<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>It seems that a commandline can not have more then 31.000 characters.<o:p></o:p></pre><pre>(no not options but total lenght)<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>Thanks, Greetings and nice Day/Evening<o:p></o:p></pre><pre> Michelle Konzack<o:p></o:p></pre><pre><o:p> </o:p></pre><p class=MsoNormal>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:<br><br><br><o:p></o:p></p><pre>cd /etc/bind<o:p></o:p></pre><pre>for FILE in *.signed<o:p></o:p></pre><pre>do<o:p></o:p></pre><pre> grep --regexp=" IN CNAME .*${QUERY}" ${FILE} 2>/dev/null |cut -d ' ' -f1 |sed 's|.$||'<o:p></o:p></pre><pre>done<o:p></o:p></pre><p class=MsoNormal>It might still have the same issue, but worth a go.<br><br>I assume the command length is also why your not simply running "grep -h <expression> *.signed"?<br><br>Stace<br><br><o:p></o:p></p><pre><o:p> </o:p></pre><pre><o:p> </o:p></pre><pre>_______________________________________________<o:p></o:p></pre><pre>bind-users mailing list<o:p></o:p></pre><pre><a href="mailto:bind-users@lists.isc.org">bind-users@lists.isc.org</a><o:p></o:p></pre><pre><a href="https://lists.isc.org/mailman/listinfo/bind-users">https://lists.isc.org/mailman/listinfo/bind-users</a><o:p></o:p></pre><p class=MsoNormal><o:p> </o:p></p></div></div></body></html>