Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
While fighting with today's CERT named advisory, I found myself upgrading to BIND9. During this madness, I realized I (and people before me) hadn't kept our DNS zone files to strict RFC compliance, and therefore BIND9 wouldn't load them (it requires strict compliance to the RFC.. I guess it's the
use strict
of the BIND world)

A zone file as I had it looked as thus:
domain.com.  IN  SOA  ns.domain.com.  root.domain.com
(
  200101261 ; serial
  10800 ; refresh
  3600 ; retry
  604800 ; expire
  86400 ) ; min ttl

In the RFC, the first line has to conclude with the open paren, and I figured while I was using perl to make these modifications, I'll make it look like so:
domain.com. IN SOA  ns.domain.com. root.domain.com (
  200101261 10800 3600 604800 86400 )
Enter perl and my gross regex code.. It's probably not the best, but it worked well for me:
#!/usr/bin/perl $/=""; while(<>) { $_ =~ s/([^(]*)\n\(\n/$1 \(\n/; # Move blankline ( to SOA lin +e $_ =~ s/\(\n\s*?(\d+)[^\n]*\n\s*?(\d+)[^\n]*\n\s*?(\d+)[^\n]*\ +n\s*?(\d+)[^\n]*\n\s*?(\d+)[^\n]*\n/\(\n\t\t$1 $2 $3 $4 $5 \)\n/; print $_; };
Run that with a perl -pi and pass it your DNS zones if they were setup like mine. Only messed up three zones out of 305. Not too bad. Maybe it'll save you some time if you too are dealing with BIND. =]

-marius

In reply to Fixing up DNS Zone Files by marius

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2024-03-28 12:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found