local.pm.ex-2
changeset 32 b3cd686b8cf6
parent 31 e127de596921
equal deleted inserted replaced
31:e127de596921 32:b3cd686b8cf6
     1 # Example
       
     2 
       
     3 # remove the next line if you know, what you're doing
       
     4 #die "Sure?  You should adapt this file to your needs!";
       
     5 
       
     6 package local;
       
     7 
       
     8 # in:	zone name
       
     9 #       src ip
       
    10 # out:  0 failure ($@ contains message)
       
    11 #      !0 ok      ($@ may contain message)
       
    12 sub addZone($$) {
       
    13     my ($zone, $src) = @_;
       
    14     my $hdns = '84.19.194.5';
       
    15 
       
    16     # Filename ist für das File selbst und auch für die Konfig
       
    17     (my $file = $zone) =~ s/[\/&|]/_/g;
       
    18 
       
    19     # 84.19.194.5 ist die ip unseres hidden master
       
    20     my $transferees = $src eq $hdns ?  'localhost; key hh.schlittermann.de' : 'none';
       
    21 
       
    22     my $txt = <<__;
       
    23 {
       
    24     type slave;
       
    25     file "/etc/cache/bind/slave/$file";
       
    26     masters { $src; };
       
    27     allow-query { any; };
       
    28     allow-transfer { $transferees; };
       
    29 };
       
    30 
       
    31 __
       
    32 
       
    33     # set 
       
    34     #	allow-new-zones yes;
       
    35     # in /etc/bind/named.conf.options
       
    36     system rndc => (
       
    37 	addzone => $zone,
       
    38 	$txt
       
    39     );
       
    40 
       
    41     if ($?) {
       
    42 	warn "rndc addzone $zone failed\n";
       
    43 	return 0;
       
    44     }
       
    45 
       
    46     $@ = "zone $zone added via rndc addzone\n";
       
    47     return 1;
       
    48 
       
    49 }
       
    50 
       
    51 1;
       
    52 # vim:sts=4 sw=4 aw ai sm: