# maak named.conf from common import * forwarders = [ "172.17.8.68", # proxy1 "172.17.143.4", # proxy2 "172.20.128.98", # proxy3 "172.18.8.66", # Internet GW Jasper ] masters = [ "172.21.16.99", # rambo.CnodeLCPL.wLeiden.NET "212.61.66.38" # koolhaas.vianetworks.nl ] def gen_named_conf(node): conf = gen_header('named.conf') + """ options { directory "/var/db/namedb"; forward only; forwarders { %s; }; query-source %s; }; zone "." { type hint; file "/etc/namedb/named.root"; }; zone "0.0.127.IN-ADDR.ARPA" { type master; file "/etc/namedb/localhost.rev"; }; zone "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.INT" { type master; file "/etc/namedb/localhost-v6.rev"; }; """ % (";\n\t\t".join(forwarders), showaddr(node.master_ip)) for zone in ["wleiden.net"] + map(lambda i: "%d.172.in-addr.arpa" % i, range(16, 32)): conf = conf + """zone "%s" { type slave; file "slave-%s"; masters { %s; }; }; """ % (zone, zone, "; ".join(masters)) return conf if __name__ == "__main__": nodes = xml_to_obj_hierarchy(sys.argv[1]) ready_nodes_dtd_hierarchy(nodes) node = findnode(nodes, sys.argv[2]) print gen_named_conf(node)