[Pdns-users] Duplicate SOA while using dig and zone2sql

Eugene Pefti eugenep at w3media.net
Wed Apr 23 17:04:52 UTC 2008


Hi Ton,

This is almost exactly what I do with shell and utilities. My script looks
like this:

 

#!/bin/bash


DNSSERVER=xxx.xxx.xxx.xxx


DOMAINARRAY=`cat /dist/importlist`


for DOMAIN in $DOMAINARRAY;


do


dig @$DNSSERVER $DOMAIN AXFR > /dist/list/$DOMAIN;


zone2sql --zone=/dist/list/$DOMAIN --gmysql --zone-name=$DOMAIN | mysql -D
pdns -u root                                                              

done


exit 0  

 

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.

 

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?

 

Eugene 

 

From: Ton van Rosmalen [mailto:ton at netbase.nl] 
Sent: Wednesday, April 23, 2008 12:39 AM
To: Eugene Pefti
Cc: pdns-users at mailman.powerdns.com
Subject: Re: [Pdns-users] Duplicate SOA while using dig and zone2sql

 

Eugene,

I'd suggest some shell-scripting to do the trick

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:

for zone in `cat zonelist`; do dig @xxx.xxx.xxx.xxx $zone AXFR >
/tmp/$zone.$$; zone2sql --gmysql --zone=/tmp/$zone.$$; rm /tmp/$zone.$$;
done

This dumps all sql-commands to your tty. Redirecting output to a file gives
you the possibility to execute the sql-script using mysql.

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!

Ton

Eugene Pefti schreef: 

Thanks Ton, I figured it too. How would you suggest to use zone2sql to get
rid of the second SOA RR?
 
Eugene 
 
-----Original Message-----
From: Ton van Rosmalen [mailto:ton at netbase.nl] 
Sent: Wednesday, April 23, 2008 12:08 AM
To: Eugene Pefti
Cc: pdns-users at mailman.powerdns.com
Subject: Re: [Pdns-users] Duplicate SOA while using dig and zone2sql
 
Hi Eugene,
 
Eugene Pefti schreef:
  

Can anybody tell me why this doesn't work:
 
#dig axfr domain.tld @xxx.xxx.xxx.xxx | zone2sql --gmysql --zone=- | mysql
-u root -D pdns
 
I do exactly what is said in pdns documentation, my problem is --zone=- is
not understood just because "-" option doesn't work. 
 
 
    

----------------------------------------------------------------------------
  

-
died because of STL error: Unable to open file '-': No such file or
directory
 
    

----------------------------------------------------------------------------
  

-
  
    

I've checked the source-code (latest svn-version and the one I use 
myself) and as far as I can tell no
code is available to handle the special case of 'zone=-'.
 
Zone2sql just tries to 'fopen' the filename and throws an error because 
it can't open '-'. Perhaps STL
should handle the special filename but I'm not familiar enough with STL 
to answer that question.
  

<snip>
  
    

 
So it looks like the documentation is ahead of the code in this case.
 
Kind regards,
 
Ton
 
  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.powerdns.com/pipermail/pdns-users/attachments/20080423/312e9418/attachment-0001.html>


More information about the Pdns-users mailing list