Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Fixing up DNS Zone Files

by marius (Hermit)
on Jan 30, 2001 at 09:11 UTC ( #55183=CUFP: 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:  IN  SOA
  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: IN SOA (
  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. =]


Replies are listed 'Best First'.
Re: Fixing up DNS Zone Files
by Anonymous Monk on Feb 05, 2001 at 08:37 UTC
    Lucky you - I decided to only go as far as 8.2.2 => 8.2.3, and still found at least half a dozen different types of error that caused zones to be rejected. Mind, there are about 140,000 zones on our nameservers.

    The code I ended up with is way to ugly to post; come on Matthew, roll on with DNS::ZoneFile. :)

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://55183]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2023-02-01 12:15 GMT
Find Nodes?
    Voting Booth?

    No recent polls found