#!/bin/sh # # dnsroot - convert the root zone file to tinydns-data format # # Toby Betts # # See for details and # the original ./cleanup script. echo .::127.53.0.1 awk ' BEGIN { OFS = ":" } { if ("." == substr($0,1,1)) { next } if ("NS" == $4) { d = substr($1,0,length($1)) if ("." == substr(d,length(d),1)) { d = substr(d,0,length($1) - 1) } ns[d] = $5 " " ns[d] next } if ("A" == $4) { ip[$1] = $5 " " ip[$1] next } } END { for (q in ns) { split(ns[q],x) for (i in x) { split(ip[x[i]],y) for (j in y) { if (y[j] != "") { print "&" q "::" y[j] } } } } } '