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