]> git.sesse.net Git - nms/blob - config/make-named.pl
Timestamp named.pl too.
[nms] / config / make-named.pl
1 #! /usr/bin/perl -w
2 use strict;
3
4 my $date = `date --rfc-2822`;
5 chomp $date;
6
7 # les inn nettnavn
8 my %netnames = ();
9 my %netmasks = ();
10 my @nets = ();
11 open NAMES, "switches.txt"
12 or die "switches.txt: $!";
13 while (<NAMES>) {
14         chomp;
15         /194\.0\.(\d+\.\d+)\s+(\d+)\s+(\S+)/ or next;
16         $netmasks{$1} = $2;
17         $netnames{$1} = $3;
18         push @nets, $1;
19 }
20
21 print <<"EOF";
22 // Autogenerated by make-named.pl at $date. Do not edit manually! 
23
24 options {
25         directory "/etc/bind";
26         allow-query { any; };
27         allow-transfer { 194.19.3.20; 194.0.255.2; }; 
28         auth-nxdomain no;
29         recursion yes;
30
31 //      forwarders { 194.19.2.11; 194.19.3.11; }; 
32 //      forward only;
33 };
34
35 zone "." { type hint; file "db.root"; };
36
37 zone "0.0.127.in-addr.arpa" {
38         type master;
39         file "0.0.127.in-addr.arpa";
40         notify no;
41 };
42
43 zone "tg07.gathering.org" {
44         type master;
45         file "tg07.gathering.org";
46         notify yes;
47         allow-transfer { 194.0.255.2; };
48 };
49
50 // serversubnett
51 zone "255.76.87.in-addr.arpa" {
52         type master;
53         file "255.76.87.in-addr.arpa";
54         notify yes;
55         allow-transfer { 194.0.255.2; 193.0.0.0/22; };
56 };
57
58 zone "76.87.in-addr.arpa" {
59         type master;
60         allow-update { key DHCP_UPDATER; };
61         notify yes;
62         file "dynamic/76.87.in-addr.arpa";      
63         allow-transfer { 194.19.3.20; 194.0.255.2; 193.0.0.0/22; };
64 };
65
66 key DHCP_UPDATER {
67         algorithm HMAC-MD5.SIG-ALG.REG.INT;
68         secret F388UOhaIIKHRH9TDE5PTA==;
69 };
70
71 EOF
72
73 for my $net (@nets) {
74         my $domain = $netnames{$net};
75         my @domains;
76         if ($domain =~ /^split:(.*)/) {
77                 @domains = split /,/, $1;
78         } else {
79                 @domains = ($domain);
80         }
81
82         for my $d (@domains) {
83                 print <<"EOF";
84 zone "$d.tg07.gathering.org" {
85         type master;
86         allow-update { key DHCP_UPDATER; };
87         notify yes;
88         file "dynamic/$d.tg07.gathering.org";
89         allow-transfer { 194.19.3.20; 194.0.255.2; };
90 };
91 EOF
92         }
93 }