Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Easy Zone - DNS Zone abstraction module

Project description


DNSZone is a package to manage the common record types of a zone file, including SOA records. This module sits on top of the dnspython package and provides a higher level abstraction for common zone file manipulation use cases. https://github.come/greg-hellings/dnszone

Main features:

  • A high-level abstraction on top of dnspython.
  • Load a zone file into objects.
  • Modify/add/delete zone/record objects.
  • Save back to zone file.
  • Auto-update serial (if necessary).




$ python build


$ python test


$ python install

OR with setuptools:

$ easy_install dnszone



>>> from dnszone import dnszone
>>> z = dnszone.zone_from_file('', '/var/namedb/')
>>> z.domain
>>> z.root.soa.serial
>>> z.root.records('NS').items
['', '']
>>> z.root.records('MX').items
[(10, ''), (20, '')]
>>> z.names[''].records('A').items

>>> ns = z.root.records('NS')
>>> ns.add('')
>>> ns.items
['', '', '']
>>> ns.delete('')
>>> ns.items
['', '']



>>> from dnszone.zone_check import ZoneCheck
>>> c = ZoneCheck()
>>> c.isValid('', '/var/named/zones/')
>>> c.isValid('', '/var/named/zones/')
>>> c.error
'Bad syntax'
>>> c = ZoneCheck(checkzone='/usr/sbin/named-checkzone')
>>> c.isValid('', '/var/named/zones/')


>>> from dnszone.zone_reload import ZoneReload
>>> r = ZoneReload()
>>> r.reload('')
zone reload up-to-date
>>> r.reload('')
rndc: 'reload' failed: not found
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "dnszone/", line 51, in reload
    raise ZoneReloadError("rndc failed with return code %d" % r)
dnszone.zone_reload.ZoneReloadError: rndc failed with return code 1
>>> r = ZoneReload(rndc='/usr/sbin/rndc')
>>> r.reload('')
zone reload up-to-date

Project details

Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for dnszone, version 2.0.0
Filename, size File type Python version Upload date Hashes
Filename, size dnszone-2.0.0-py3-none-any.whl (8.8 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size dnszone-2.0.0.tar.gz (7.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page