annotate scripts/nameserver_autogen/bind_tld_zonefile_all.sh @ 1190:dae39c508416 draft

updated the bind_tld_zonefile_all.sh for 21.0.0.0/8
author epoch <epoch@hacking.allowed.ano>
date Thu, 09 Mar 2017 23:58:05 +0000
parents 135e7c234e24
children 56c959ab3e05
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1170
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
1 #!/bin/bash
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
2 #made for bash. not sure if all /bin/sh work.
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
3 #be sure to edit these variables first.
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
4
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
5 #ZONEFILE_DIR=/etc/namedb
1190
dae39c508416 updated the bind_tld_zonefile_all.sh for 21.0.0.0/8
epoch <epoch@hacking.allowed.ano>
parents: 1182
diff changeset
6 RDNS_ZONEFILE=/etc/namedb/21.in-addr.arpa
1170
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
7 #RESDB_PATH=/var/db/resdb
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
8
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
9 if [ ! "$ZONEFILE_DIR" ];then
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
10 echo "You forgot to set some variables. read the source plzkthx."
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
11 exit 0;
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
12 fi
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
13
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
14
1190
dae39c508416 updated the bind_tld_zonefile_all.sh for 21.0.0.0/8
epoch <epoch@hacking.allowed.ano>
parents: 1182
diff changeset
15 echo -n "generating ipv4 reverse lookup zonefile for 21/8..."
1170
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
16
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
17 echo "; this zonefile genreated on: `date`" > "$RDNS_ZONEFILE"
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
18 echo '$TTL 3600' >> "$RDNS_ZONEFILE"
1182
135e7c234e24 updated them to have no out-of-zone data.
epoch <epoch@hacking.allowed.ano>
parents: 1170
diff changeset
19 echo '@ IN SOA @ root ('`date +" %Y%m%d%H"`' 60 300 3600000 3600 )' >> "$RDNS_ZONEFILE"
135e7c234e24 updated them to have no out-of-zone data.
epoch <epoch@hacking.allowed.ano>
parents: 1170
diff changeset
20 echo '@ IN NS @' >> "$RDNS_ZONEFILE"
135e7c234e24 updated them to have no out-of-zone data.
epoch <epoch@hacking.allowed.ano>
parents: 1170
diff changeset
21 echo '@ IN A 127.0.0.1' >> "$RDNS_ZONEFILE"
1170
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
22
1190
dae39c508416 updated the bind_tld_zonefile_all.sh for 21.0.0.0/8
epoch <epoch@hacking.allowed.ano>
parents: 1182
diff changeset
23 for i in `ls ${RESDB_PATH}/db/ip/15/*/*/ns/*`;do #this is for 21.
1170
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
24 f=$(basename $i)
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
25 a=$(basename $(dirname $i))
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
26 b=$(basename $(dirname $(dirname $i)))
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
27 c=$(basename $(dirname $(dirname $(dirname $i))))
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
28 printf "%d.%d IN NS %s\n" $[0x${b}] $[0x${c}] ${f}.
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
29 done >> "$RDNS_ZONEFILE"
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
30 echo done.
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
31
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
32 for GOHERE in ${RESDB_PATH}/db/dom/*;do
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
33
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
34 cd ${GOHERE}
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
35 TLD=$(basename ${GOHERE})
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
36 ANO_ZONEFILE=${ZONEFILE_DIR}/${TLD}
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
37 echo -n generating .${TLD} TLD zonefile...
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
38 echo "; this zonefile genreated on: `date`" > "$ANO_ZONEFILE"
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
39 echo '$TTL 3600' >> "$ANO_ZONEFILE"
1182
135e7c234e24 updated them to have no out-of-zone data.
epoch <epoch@hacking.allowed.ano>
parents: 1170
diff changeset
40 echo '@ IN SOA @ root ('`date +" %Y%m%d%H"`' 60 300 3600000 3600 )' >> "$ANO_ZONEFILE"
135e7c234e24 updated them to have no out-of-zone data.
epoch <epoch@hacking.allowed.ano>
parents: 1170
diff changeset
41 echo '@ IN NS @' >> "$ANO_ZONEFILE"
135e7c234e24 updated them to have no out-of-zone data.
epoch <epoch@hacking.allowed.ano>
parents: 1170
diff changeset
42 echo '@ IN A 127.0.0.1' >> "$ANO_ZONEFILE"
1170
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
43
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
44 for name in *;do
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
45 if [ -e "${name}/ns/" ];then
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
46 for server in "$name"/ns/*;do
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
47 if grep '\.ano$' <<< "$name" > /dev/null;then
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
48 true
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
49 fi
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
50 if grep '\.ano$' <<< "$server" > /dev/null;then
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
51 true
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
52 fi
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
53 fqserver=`cut -d/ -f3- <<< $server`
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
54 echo -e "${name}\tIN NS\t${fqserver}."
1190
dae39c508416 updated the bind_tld_zonefile_all.sh for 21.0.0.0/8
epoch <epoch@hacking.allowed.ano>
parents: 1182
diff changeset
55 for ip in $(cat ${server});do
1170
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
56 if grep ':' <<< "$ip" > /dev/null;then
1190
dae39c508416 updated the bind_tld_zonefile_all.sh for 21.0.0.0/8
epoch <epoch@hacking.allowed.ano>
parents: 1182
diff changeset
57 printf '%s.\tIN AAAA\t%s\n' "${fqserver}" "${ip}"
1170
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
58 else
1190
dae39c508416 updated the bind_tld_zonefile_all.sh for 21.0.0.0/8
epoch <epoch@hacking.allowed.ano>
parents: 1182
diff changeset
59 printf '%s.\tIN A\t%s\n' "${fqserver}" "${ip}"
1170
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
60 fi
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
61 done
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
62 done
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
63 fi
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
64 done >> "$ANO_ZONEFILE"
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
65 echo done with ${TLD}
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
66 done
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
67
44da84ec0c43 forked bind_told_zonefile.sh to do all TLDs in resdb instead of just ano.
epoch <epoch@hacking.allowed.ano>
parents:
diff changeset
68 echo might want to send a sighup to your named now.