Easy Zone - DNS Zone abstraction module
Project description
Overview
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.
http://pypi.python.org/pypi/dnszone 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).
Requirements
dnspython - http://www.dnspython.org/
Build/Test/Install
Build:
$ python setup.py build
Test:
$ python setup.py test
Install:
$ python setup.py install
OR with setuptools:
$ easy_install dnszone
Examples
dnszone:
>>> from dnszone import dnszone >>> z = dnszone.zone_from_file('example.com', '/var/namedb/example.com') >>> z.domain 'example.com.' >>> z.root.soa.serial 2007012902L >>> z.root.records('NS').items ['ns1.example.com.', 'ns2.example.com.'] >>> z.root.records('MX').items [(10, 'mail.example.com.'), (20, 'mail2.example.com.')] >>> z.names['foo.example.com.'].records('A').items ['10.0.0.1'] >>> ns = z.root.records('NS') >>> ns.add('ns3.example.com.') >>> ns.items ['ns1.example.com.', 'ns2.example.com.', 'ns3.example.com.'] >>> ns.delete('ns2.example.com') >>> ns.items ['ns1.example.com.', 'ns3.example.com.'] >>> z.save(autoserial=True)
ZoneCheck:
>>> from dnszone.zone_check import ZoneCheck >>> c = ZoneCheck() >>> c.isValid('example.com', '/var/named/zones/example.com') True >>> c.isValid('foo.com', '/var/named/zones/example.com') False >>> c.error 'Bad syntax' >>> >>> c = ZoneCheck(checkzone='/usr/sbin/named-checkzone') >>> c.isValid('example.com', '/var/named/zones/example.com') True >>>
ZoneReload:
>>> from dnszone.zone_reload import ZoneReload >>> r = ZoneReload() >>> r.reload('example.com') zone reload up-to-date >>> r.reload('foo.com') rndc: 'reload' failed: not found Traceback (most recent call last): File "<stdin>", line 1, in <module> File "dnszone/zone_reload.py", 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('example.com') zone reload up-to-date >>>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dnszone-2.0.0.tar.gz
.
File metadata
- Download URL: dnszone-2.0.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 306dbf5494c3fed2429325b8786649a73bb2ccbe5e4ab385dab888f98fd826ec |
|
MD5 | d2455257caf030a689d53ce62d849385 |
|
BLAKE2b-256 | 50073138f559f95414cc9ec9c14e57cee2ac7b96c151c82e426febf52b512dd0 |
File details
Details for the file dnszone-2.0.0-py3-none-any.whl
.
File metadata
- Download URL: dnszone-2.0.0-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 123d021edb6eac6a694982edf6b045cc23ce905ccec038d86abaebefe676f101 |
|
MD5 | 18b3fc7dade249e081fd8e477141536a |
|
BLAKE2b-256 | c9374904cce1d8f96a8536540f5fb4bd230f9fe1c3a9c28e637ebe9fc221c143 |