diff --git a/bind/lixo.rpz.whitelist.tmpl b/bind/lixo.rpz.whitelist.tmpl index f7a229a..69131e8 100644 --- a/bind/lixo.rpz.whitelist.tmpl +++ b/bind/lixo.rpz.whitelist.tmpl @@ -10,3 +10,5 @@ ${tld:-lixo} CNAME rpz-passthru. *.${tld:-lixo} CNAME rpz-passthru. +{{ range "$root_reverse_zones" | split "," }}*.{{ . }} CNAME rpz-passthru. +{{ end }} diff --git a/bind/named.conf.tmpl b/bind/named.conf.tmpl index 1cf5e65..f8670d7 100644 --- a/bind/named.conf.tmpl +++ b/bind/named.conf.tmpl @@ -59,6 +59,14 @@ view "lixonet" { forward only; forwarders { ${bind_forward_address-"${internal_gateway}"}; }; }; + + # Local reverse zone forwarders + {{ if len "${local_reverse_zones:-}" }}{{ range "$local_reverse_zones" | split "," }}zone "{{ . }}" { + type forward; + forward only; + forwarders { ${bind_forward_address-"${internal_gateway}"}; }; + }; + {{ end }}{{ end }} # Peer forwarding zones {{ range files "bind/peers" }} {{ if ne . "${tinc_peer_name}" }} @@ -69,10 +77,10 @@ view "lixonet" { };{{ end }}{{ end }} # Custom mesh zones - {{ range files "bind/zones" }} - zone "{{ . | replace "_" "." }}" { + {{ range files "bind/zones" }}zone "{{ . | replace "_" "." }}" { {{ include (print "bind/zones/" .) }} - };{{ end }} + }; + {{ end }} }; view "default" { diff --git a/build.sh b/build.sh index c9b7984..58a7bda 100644 --- a/build.sh +++ b/build.sh @@ -7,6 +7,8 @@ process_template ( ) { rm $1 } +function join_by { local IFS="$1"; shift; echo "$*"; } + process_templates ( ) { for template_filename in `find $1 -type f -name '*.tmpl'` do @@ -18,8 +20,6 @@ topdir=`pwd` for dir in `find /etc/lixonet/* -type d -maxdepth 0` do - echo "Inspecting $dir..." - dir=${dir%*/} # remove the trailing "/" netname=${dir##*/} # print everything after the final "/" @@ -29,6 +29,12 @@ do if [ -z "$git" ]; then echo "Missing 'git' variable in $dir/lixonet.conf"; exit 1; fi sigil_vars=$(cat /etc/lixonet/${netname}/lixonet.conf | tr "\\n" " ") + # Parse subnets into a collection of IP reverse zones + root_reverse_zones=$(echo '${network_address}/${global_prefix:-16}' | sigil -p $sigil_vars | xargs -I '{}' netcalc split {} 24 | sed 's/.0\/24$//' | awk 'BEGIN{FS="."}{print $3"."$2"."$1".in-addr.arpa"}' | sed -e ':a;N;$!ba;s/\n/,/g') + sigil_vars=$(echo "$sigil_vars root_reverse_zones=$root_reverse_zones") + local_reverse_zones=$(echo "$bgp_routes" | tr "," "\n" | xargs -I '{}' netcalc split {} 24 | sed 's/.0\/24$//' | awk 'BEGIN{FS="."}{print $3"."$2"."$1".in-addr.arpa"}' | sed -e ':a;N;$!ba;s/\n/,/g') + sigil_vars=$(echo "$sigil_vars local_reverse_zones=$local_reverse_zones") + echo "Configuring Lixonet3 network $netname from $git..." echo "Variables: $sigil_vars"