File: bld2zone.pl

package info (click to toggle)
bld 0.3.4.1-4
  • links: PTS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, squeeze, stretch, wheezy
  • size: 576 kB
  • ctags: 268
  • sloc: ansic: 2,333; sh: 175; makefile: 157; perl: 135; python: 36
file content (41 lines) | stat: -rwxr-xr-x 653 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/perl
#
# Converts a bld dump printed by bldread to a zone file.
#
# Olivier Beyssac <obld@r14.freenix.org>
#

use Date::Format;
use strict;

my $domain = "FILLME";
my $ns0 = "FILLME";
my $ip0 = "FILLME";
my $ns1 = "FILLME";
my $ip1 = "FILLME";

my $date = time2str("%Y%m%d%H", time());

print <<EOF
\$TTL 1800
$domain. IN SOA $ns0. postmaster.$ns0 (
  $date
  21600
  7200
  3600000
  7200)

@ IN NS $ns0.
@ IN NS $ns1.
ns0 IN A $ip0
ns1 IN A $ip1

; Blacklist begins here
EOF
;

while (<>) {
    if (/^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+);/) {
	print "$4.$3.$2.$1 IN A 127.0.0.1\n\t\tTXT \"Blacklisted by postmaster\@$domain\"\n";
    }
}