<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 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@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:0in;
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:0in;
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 Section1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
{page:Section1;}
-->
</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=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Hi Ton,<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>This is almost exactly what I do with shell and utilities. My
script looks like this:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>#!/bin/bash
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>DNSSERVER=xxx.xxx.xxx.xxx
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>DOMAINARRAY=`cat
/dist/importlist`
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>for DOMAIN in
$DOMAINARRAY;
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>do <o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>dig @$DNSSERVER $DOMAIN AXFR >
/dist/list/$DOMAIN;
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>zone2sql --zone=/dist/list/$DOMAIN --gmysql --zone-name=$DOMAIN
| mysql -D pdns -u root <o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>done
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>exit 0 <o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>The problem is inherent to zone2sql. Like Bert mentioned AXFR ends
its output with one more SOA RR. I hoped that zone2sql takes care about this
duplicate but in vain.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>May I ask you a question, Ton? Why do you append the process ID
to the zone file in your script? Just to make it more verbose?<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Eugene <o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<div>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>
<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";
color:windowtext'>From:</span></b><span style='font-size:10.0pt;font-family:
"Tahoma","sans-serif";color:windowtext'> Ton van Rosmalen
[mailto:ton@netbase.nl] <br>
<b>Sent:</b> Wednesday, April 23, 2008 12:39 AM<br>
<b>To:</b> Eugene Pefti<br>
<b>Cc:</b> pdns-users@mailman.powerdns.com<br>
<b>Subject:</b> Re: [Pdns-users] Duplicate SOA while using dig and zone2sql<o:p></o:p></span></p>
</div>
</div>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Eugene,<br>
<br>
I'd suggest some shell-scripting to do the trick<br>
<br>
Create a file containing the zones the check. One zone per line, in the sample
below I've used the name 'zonelist'. Then execute the following script:<br>
<br>
for zone in `cat zonelist`; do dig @xxx.xxx.xxx.xxx $zone AXFR >
/tmp/$zone.$$; zone2sql --gmysql --zone=/tmp/$zone.$$; rm /tmp/$zone.$$; done<br>
<br>
This dumps all sql-commands to your tty. Redirecting output to a file gives you
the possibility to execute the sql-script using mysql.<br>
<br>
If you want to keep the dig-output just remove the 'rm /tmp/$zone.$$'. Beware,
running the script again creates all zone-files again in /tmp!<br>
<br>
Ton<br>
<br>
Eugene Pefti schreef: <o:p></o:p></p>
<pre>Thanks Ton, I figured it too. How would you suggest to use zone2sql to get<o:p></o:p></pre><pre>rid of the second SOA RR?<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>Eugene <o:p></o:p></pre><pre><o:p> </o:p></pre><pre>-----Original Message-----<o:p></o:p></pre><pre>From: Ton van Rosmalen [<a
href="mailto:ton@netbase.nl">mailto:ton@netbase.nl</a>] <o:p></o:p></pre><pre>Sent: Wednesday, April 23, 2008 12:08 AM<o:p></o:p></pre><pre>To: Eugene Pefti<o:p></o:p></pre><pre>Cc: <a
href="mailto:pdns-users@mailman.powerdns.com">pdns-users@mailman.powerdns.com</a><o:p></o:p></pre><pre>Subject: Re: [Pdns-users] Duplicate SOA while using dig and zone2sql<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>Hi Eugene,<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>Eugene Pefti schreef:<o:p></o:p></pre><pre> <o:p></o:p></pre>
<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>Can anybody tell me why this doesn't work:<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>#dig axfr domain.tld @xxx.xxx.xxx.xxx | zone2sql --gmysql --zone=- | mysql<o:p></o:p></pre><pre>-u root -D pdns<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>I do exactly what is said in pdns documentation, my problem is --zone=- is<o:p></o:p></pre><pre>not understood just because "-" option doesn't work. <o:p></o:p></pre><pre><o:p> </o:p></pre><pre><o:p> </o:p></pre><pre> <o:p></o:p></pre></blockquote>
<pre>----------------------------------------------------------------------------<o:p></o:p></pre><pre> <o:p></o:p></pre>
<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>-<o:p></o:p></pre><pre>died because of STL error: Unable to open file '-': No such file or<o:p></o:p></pre><pre>directory<o:p></o:p></pre><pre><o:p> </o:p></pre><pre> <o:p></o:p></pre></blockquote>
<pre>----------------------------------------------------------------------------<o:p></o:p></pre><pre> <o:p></o:p></pre>
<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>-<o:p></o:p></pre><pre> <o:p></o:p></pre><pre> <o:p></o:p></pre></blockquote>
<pre>I've checked the source-code (latest svn-version and the one I use <o:p></o:p></pre><pre>myself) and as far as I can tell no<o:p></o:p></pre><pre>code is available to handle the special case of 'zone=-'.<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>Zone2sql just tries to 'fopen' the filename and throws an error because <o:p></o:p></pre><pre>it can't open '-'. Perhaps STL<o:p></o:p></pre><pre>should handle the special filename but I'm not familiar enough with STL <o:p></o:p></pre><pre>to answer that question.<o:p></o:p></pre><pre> <o:p></o:p></pre>
<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre><snip><o:p></o:p></pre><pre> <o:p></o:p></pre><pre> <o:p></o:p></pre></blockquote>
<pre><o:p> </o:p></pre><pre>So it looks like the documentation is ahead of the code in this case.<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>Kind regards,<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>Ton<o:p></o:p></pre><pre><o:p> </o:p></pre><pre> <o:p></o:p></pre></div>
</body>
</html>