#!/usr/local/bin/perl -p # # Convert a master config file to a slave config with master. # by nate campi # # This script expects a conf file on STDIN, use it like this: # $ cat named.zones | convert-slave # # See http://www.campin.net/DNS/ for usage info. # put in the IP of your master DNS server here: $MASTER = "123.123.123.123"; # zero out lines I don't want SWITCH: { /include/ && do { chomp; $_ =~ s/.*// ; last SWITCH; }; /also-notify/ && do { chomp; $_ =~ s/.*// ; last SWITCH; }; /allow-transfer/ && do { chomp; $_ =~ s/.*// ; last SWITCH; }; } if (/^[ \t]*zone/) { @line = split(/\s+/); # split it for easy parsing # print "\$line[0] is: $line[0]\n"; # print "\$line[1] is: $line[1]\n"; } # lose the quotes $line[1] =~ s/^"(.*)"/$1/ ; # some zone names have slashes in them $line[1] =~ s|/|_| ; # this is what we're here for s/^([#\/\s]*)type\s+master\s*;/$1type slave;\n$1masters { $MASTER; };/; s/master\//slave\//; # sub dir name with "secondary" and change the filename to match the domain name s/^([#\/\s]*file\s+").*\/(.*)/$1secondary\/$line[1]";/;