Single slave zone definition for two view (cache file name problem)

Tony Finch dot at dotat.at
Tue Mar 17 16:34:29 UTC 2015


Constantin Stefanov <cstef at parallel.ru> wrote:
>
> I found 'in-view' option, but again it requires two definitions for
> every zone: one with "file" and "masters" directives, and another with
> "in-view" option. Moreover, these two definitions must be in different
> files, as I have to include one in first view, and another (with
> 'in-view') in all other views, so I have to keep two separate files
> synced with one another.

I have a similar situation on my workstation server, except in my case the
recursive view needs static-stub configurations for each zone in the
authoritative view.

I have a script called named-listzones (attached) which reads named.conf
and outputs a list of zone name, view, and type. A bit of seddery in the
rc script re-generates the static-stub zone configuration whenever named
is started or reloaded.

named-listzones | sed '
/ auth master$/bp
/ auth slave$/bp
d
:p
s// { type static-stub; server-addresses { ::1; }; };/
s/^/zone /
/"[.]"/d
' >named.static-stub

Tony.
-- 
f.anthony.n.finch  <dot at dotat.at>  http://dotat.at/
Biscay, Fitzroy: East or northeast 5 or 6, occasionally 7 in south Fitzroy.
Moderate or rough. Showers. Moderate or good.
-------------- next part --------------
#!/usr/bin/perl

use warnings;
use strict;
use re 'eval';

our $string_re = qr( " (?: [^"\\] | \\. )* " )x;
our $atom_re = qr( (?! zone \s+ | view \s+ )
		   [0-9A-Za-z!:._/-]+ )x;
our $stuff_re = qr(  $string_re
		  |     $atom_re
		  | (??{$block_re})
		  | \s+ | ;
		  )x;
our $block_re = qr( { (?: $stuff_re )+ } \s* ; )x;

our $type_re = qr( type \s+ ($atom_re) \s* ; )x;

my $conf = qx{named-checkconf -p @ARGV};

sub zone {
	my ($zone,$view) = @_;
	$conf =~ m(^ $type_re )x;
	print "$zone $view $1\n";
	$conf =~ s(^ $stuff_re )()x
	    until $conf =~ s(^ } \s* ; )()x;
}

my $head_re = qr(\s+ ($string_re) \s+ (?: ($atom_re) \s+ )? { \s*)x;

while ($conf =~ s(^ $stuff_re )()x) {
	next unless $conf =~ s(^ (zone|view) $head_re )()x;
	my $name = $2;
	my $class = $4 || "IN";
	if ($1 eq 'zone') {
		zone $name, '_default', $class;
	} else { # view
		my $view = substr $name, 1, -1;
		for (;;) {
			last if $conf =~ s(^ } \s* ; )()x;
			if ($conf =~ s(^ zone $head_re )()x) {
				zone $1, $view, $2 || "IN";
			}
			last unless $conf =~ s(^ $stuff_re )()x;
		}
	}
}

die "parser failure\n" if $conf !~ m(^$);


More information about the bind-users mailing list