I have a painful DNS issue, so I'm writing a script to pull all the records
from multiple forward zones and then generating the reverse zone files.
My issue that I'm seeing is when i write back my zone file with
zone.to_file(new_zone_file) the PTR records are not properly terminated
with a '.'
Here's the code that actually rewrites the zone.
arpa_zones is a dict of lists, the key is the zone name (10.in-addr.arpa
for example) and the list contents are tuples of Name objects (arpa_addr,
target_name)
zone = dns.zone.from_file("%s/%sdb" % (zone_path,key),key)
for (name, ttl, rdata) in zone.iterate_rdatas(SOA):
serial = rdata.serial
new_serial = serial + 1
rdata.serial = new_serial
# zone.iterate_rdatas is a generator, so we have to get all the
name objects
# THEN delete them, or the list shrinks during generation
old_recs = []
for (name,ttl,rdata) in zone.iterate_rdatas(PTR):
old_recs.append(name)
for rec in old_recs:
zone.delete_node(rec)
for node in arpa_zones[key]:
rdataset = zone.find_rdataset(node[0], rdtype=PTR,
create=True)
rdata = dns.rdtypes.ANY.PTR.PTR(IN,PTR,target=node[1])
rdataset.add(rdata,ttl=3600)
Output appears like this:
21.0.4 3600 IN PTR annemnmom01.tech.local
22.0.4 3600 IN PTR annemnmom02.tech.local
24.0.4 3600 IN PTR snmp_sim.tech.local
Expected output should be
21.0.4 3600 IN PTR annemnmom01.tech.local. <-- note the trailing .
22.0.4 3600 IN PTR annemnmom02.tech.local.
24.0.4 3600 IN PTR snmp_sim.tech.local.
Any suggestions?
_______________________________________________
dnspython-users mailing list
[email protected]
http://howl.play-bow.org/mailman/listinfo/dnspython-users