]> git.sesse.net Git - nms/blob - config/make-named.pl
Added make-named.pl from TG05.
[nms] / config / make-named.pl
1 #! /usr/bin/perl -w
2 use strict;
3
4 # les inn nettnavn
5 my %netnames = ();
6 my %netmasks = ();
7 my @nets = ();
8 open NAMES, "switches.txt"
9 or die "switches.txt: $!";
10 while (<NAMES>) {
11         chomp;
12         /81\.162\.(\d+\.\d+)\s+(\d+)\s+(\S+)/ or next;
13         $netmasks{$1} = $2;
14         $netnames{$1} = $3;
15         push @nets, $1;
16 }
17
18 print <<"EOF";
19 // Autogenerated by make-named.pl. Do not edit manually! 
20
21 options {
22         directory "/etc/bind";
23         allow-query { any; };
24         allow-transfer { 194.19.3.20; 81.162.254.76; }; 
25         auth-nxdomain no;
26         recursion yes;
27
28         forwarders { 194.19.2.11; 194.19.3.11; }; 
29         forward only;
30 };
31
32 zone "." { type hint; file "db.root"; };
33
34 zone "0.0.127.in-addr.arpa" {
35         type master;
36         file "0.0.127.in-addr.arpa";
37         notify no;
38 };
39
40 zone "tg05.gathering.org" {
41         type master;
42         file "tg05.gathering.org";
43         notify yes;
44         allow-transfer { 81.162.254.76; };
45 };
46 zone "www.gathering.org" {
47         type master;
48         file "www.gathering.org";
49         notify yes;
50         allow-transfer { 81.162.254.76; };
51 };
52
53 // serversubnett
54 zone "254.162.81.in-addr.arpa" {
55         type master;
56         file "254.162.81.in-addr.arpa";
57         notify yes;
58         allow-transfer { 81.162.254.76; 193.0.0.0/22; };
59 };
60
61 zone "162.81.in-addr.arpa" {
62         type master;
63         allow-update { key DHCP_UPDATER; };
64         notify yes;
65         file "dynamic/162.81.in-addr.arpa";     
66         allow-transfer { 194.19.3.20; 81.162.254.76; 193.0.0.0/22; };
67 };
68
69 key DHCP_UPDATER {
70         algorithm HMAC-MD5.SIG-ALG.REG.INT;
71         secret removed;
72 };
73
74 EOF
75
76 for my $net (@nets) {
77         my $domain = $netnames{$net};
78
79        my ($netmask, $numpc);
80        if ($netmasks{$net} == 24) {
81                $netmask = "255.255.255.0";
82                $numpc = 256;
83        } elsif ($netmasks{$net} == 25) {
84                $netmask = "255.255.255.128";
85                $numpc = 128;
86        } elsif ($netmasks{$net} == 26) {
87                $netmask = "255.255.255.192";
88                $numpc = 64;
89        } else {
90                die "Unknown netmask /$netmasks{$net}";
91        }
92
93        $net =~ /(\d+)\.(\d+)/ or die "Unknown net $net";
94        my ($majorsubnet,$minorsubnet) = ($1,$2);
95
96         my $gw = "82.162.$majorsubnet." . ($minorsubnet + 1);
97
98         print <<"EOF";
99 zone "$domain.tg05.gathering.org" {
100         type master;
101         allow-update { key DHCP_UPDATER; };
102         notify yes;
103         file "dynamic/$domain.tg05.gathering.org";
104         allow-transfer { 194.19.3.20; 81.162.254.76; };
105 };
106 EOF
107 }