netbox-pdns-connector 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- netbox_pdns_connector-0.1.2/LICENSE +190 -0
- netbox_pdns_connector-0.1.2/PKG-INFO +156 -0
- netbox_pdns_connector-0.1.2/README.md +126 -0
- netbox_pdns_connector-0.1.2/pyproject.toml +59 -0
- netbox_pdns_connector-0.1.2/setup.cfg +4 -0
- netbox_pdns_connector-0.1.2/src/netbox_pdns_connector/__init__.py +30 -0
- netbox_pdns_connector-0.1.2/src/netbox_pdns_connector/crypto_util.py +29 -0
- netbox_pdns_connector-0.1.2/src/netbox_pdns_connector/forms.py +47 -0
- netbox_pdns_connector-0.1.2/src/netbox_pdns_connector/jobs.py +77 -0
- netbox_pdns_connector-0.1.2/src/netbox_pdns_connector/migrations/0001_initial.py +70 -0
- netbox_pdns_connector-0.1.2/src/netbox_pdns_connector/migrations/__init__.py +0 -0
- netbox_pdns_connector-0.1.2/src/netbox_pdns_connector/models.py +101 -0
- netbox_pdns_connector-0.1.2/src/netbox_pdns_connector/navigation.py +23 -0
- netbox_pdns_connector-0.1.2/src/netbox_pdns_connector/pdns_client.py +271 -0
- netbox_pdns_connector-0.1.2/src/netbox_pdns_connector/reconciler.py +108 -0
- netbox_pdns_connector-0.1.2/src/netbox_pdns_connector/rrset_convert.py +148 -0
- netbox_pdns_connector-0.1.2/src/netbox_pdns_connector/signals.py +32 -0
- netbox_pdns_connector-0.1.2/src/netbox_pdns_connector/status.py +230 -0
- netbox_pdns_connector-0.1.2/src/netbox_pdns_connector/templates/netbox_pdns_connector/settings.html +38 -0
- netbox_pdns_connector-0.1.2/src/netbox_pdns_connector/templates/netbox_pdns_connector/status.html +154 -0
- netbox_pdns_connector-0.1.2/src/netbox_pdns_connector/templates/netbox_pdns_connector/zone_detail.html +111 -0
- netbox_pdns_connector-0.1.2/src/netbox_pdns_connector/urls.py +18 -0
- netbox_pdns_connector-0.1.2/src/netbox_pdns_connector/views.py +108 -0
- netbox_pdns_connector-0.1.2/src/netbox_pdns_connector.egg-info/PKG-INFO +156 -0
- netbox_pdns_connector-0.1.2/src/netbox_pdns_connector.egg-info/SOURCES.txt +28 -0
- netbox_pdns_connector-0.1.2/src/netbox_pdns_connector.egg-info/dependency_links.txt +1 -0
- netbox_pdns_connector-0.1.2/src/netbox_pdns_connector.egg-info/requires.txt +6 -0
- netbox_pdns_connector-0.1.2/src/netbox_pdns_connector.egg-info/top_level.txt +1 -0
- netbox_pdns_connector-0.1.2/tests/test_rrset_convert.py +63 -0
- netbox_pdns_connector-0.1.2/tests/test_soa_parity.py +88 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 netbox-opennebula-sync contributors
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: netbox-pdns-connector
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: NetBox plugin: push netbox_dns zones and records to PowerDNS Authoritative (REST API v1)
|
|
5
|
+
Author: NetBox PowerDNS Connector contributors
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/mael-chouteau/netbox-pdns-connector
|
|
8
|
+
Project-URL: Issues, https://github.com/mael-chouteau/netbox-pdns-connector/issues
|
|
9
|
+
Project-URL: Documentation, https://github.com/mael-chouteau/netbox-pdns-connector#readme
|
|
10
|
+
Keywords: netbox,powerdns,dns,netbox_dns,plugin,ddi
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Framework :: Django
|
|
13
|
+
Classifier: Intended Audience :: System Administrators
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Internet :: Name Service (DNS)
|
|
20
|
+
Classifier: Topic :: System :: Systems Administration
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: httpx>=0.27
|
|
25
|
+
Requires-Dist: cryptography>=42.0
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
28
|
+
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# netbox-pdns-connector
|
|
32
|
+
|
|
33
|
+
[](https://github.com/mael-chouteau/netbox-pdns-connector/actions/workflows/ci.yml)
|
|
34
|
+
[](https://pypi.org/project/netbox-pdns-connector/)
|
|
35
|
+
[](LICENSE)
|
|
36
|
+
[](https://github.com/netbox-community/netbox)
|
|
37
|
+
|
|
38
|
+
NetBox Community plugin that pushes **active** DNS zones and records from
|
|
39
|
+
[`netbox_dns`](https://github.com/sys4/netbox-plugin-dns) to one or two
|
|
40
|
+
**PowerDNS Authoritative** servers via the REST API v1.
|
|
41
|
+
|
|
42
|
+
This plugin is a **connector only**: it does **not** store zones or records.
|
|
43
|
+
Edit DNS data in **Plugins → DNS** (`netbox_dns`); this plugin syncs that data
|
|
44
|
+
to PowerDNS and shows live health / SOA serial parity.
|
|
45
|
+
|
|
46
|
+
Ideal for operators who already use NetBox + `netbox_dns` as the DNS source of
|
|
47
|
+
truth and want PowerDNS (single node or HA pair) as the serving plane.
|
|
48
|
+
|
|
49
|
+
## Features
|
|
50
|
+
|
|
51
|
+
| Area | What you get |
|
|
52
|
+
|------|----------------|
|
|
53
|
+
| **UI** | Plugins → PowerDNS → **Live Status** (API probe + zone SOA parity) + zone detail (read-only) + **Settings** |
|
|
54
|
+
| **Sync** | RQ job: *Sync now*, configurable interval, optional realtime on `netbox_dns` changes |
|
|
55
|
+
| **Targets** | Primary and optional secondary PowerDNS API URLs (shared API key supported) |
|
|
56
|
+
| **Push model** | Native zones; atomic RRset REPLACE; orphan RRset DELETE; `soa_edit_api=NONE` so NetBox owns SOA serials |
|
|
57
|
+
| **Safety** | Dry-run mode, Fernet-encrypted API key (Django `SECRET_KEY`), optional DNS view filter |
|
|
58
|
+
|
|
59
|
+
Compatible with **NetBox 4.2+** (tested on **4.7**). License: **Apache-2.0**.
|
|
60
|
+
|
|
61
|
+
## Screenshots
|
|
62
|
+
|
|
63
|
+
> Add screenshots of Live Status and Settings after first public release (optional).
|
|
64
|
+
|
|
65
|
+
## Requirements
|
|
66
|
+
|
|
67
|
+
- NetBox 4.2 or newer with **netbox-rq** running
|
|
68
|
+
- [`netbox-plugin-dns`](https://github.com/sys4/netbox-plugin-dns) installed and migrated
|
|
69
|
+
- PowerDNS Authoritative with **API** enabled (`api=yes`, `webserver=yes`)
|
|
70
|
+
- Python 3.11+
|
|
71
|
+
|
|
72
|
+
## Installation
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
/opt/netbox/venv/bin/pip install netbox-pdns-connector
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Add to `/opt/netbox/local_requirements.txt` for upgrades:
|
|
79
|
+
|
|
80
|
+
```text
|
|
81
|
+
netbox-pdns-connector
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
In `configuration.py`:
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
PLUGINS = [
|
|
88
|
+
'netbox_dns',
|
|
89
|
+
'netbox_pdns_connector',
|
|
90
|
+
]
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
sudo -u netbox /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py migrate netbox_pdns_connector
|
|
95
|
+
sudo systemctl restart netbox netbox-rq
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
1. Open **Plugins → PowerDNS → Settings**
|
|
99
|
+
2. Set primary (and optional secondary) API base URL, e.g. `http://dns1.example:8081`
|
|
100
|
+
3. Paste the PowerDNS API key (stored encrypted)
|
|
101
|
+
4. Optionally restrict sync to one `netbox_dns` **View**
|
|
102
|
+
5. Save, then **Live Status → Sync now**
|
|
103
|
+
|
|
104
|
+
The client appends `/api/v1`. Do **not** put a trailing slash on `/servers/localhost`
|
|
105
|
+
paths (PowerDNS returns 404).
|
|
106
|
+
|
|
107
|
+
## Configuration reference
|
|
108
|
+
|
|
109
|
+
| Setting | Description |
|
|
110
|
+
|---------|-------------|
|
|
111
|
+
| Primary / secondary URL | PowerDNS REST base (`http://host:8081`) |
|
|
112
|
+
| Server id | PowerDNS API server name (usually `localhost`) |
|
|
113
|
+
| API key | Shared secret; Fernet-encrypted at rest |
|
|
114
|
+
| View | Limit sync to one `netbox_dns` view (empty = all) |
|
|
115
|
+
| Sync interval | Minutes between automatic RQ runs |
|
|
116
|
+
| Realtime sync | Enqueue sync on zone/record save/delete |
|
|
117
|
+
| Dry run | Compute push without calling PowerDNS |
|
|
118
|
+
|
|
119
|
+
### PowerDNS side tips
|
|
120
|
+
|
|
121
|
+
- Restrict `webserver-allow-from` to your NetBox host
|
|
122
|
+
- Firewall API port (e.g. 8081) accordingly
|
|
123
|
+
- Zones are created as **Native** with `soa_edit` / `soa_edit_api` = **NONE** so NetBox SOA serials are preserved (PowerDNS `DEFAULT` would rewrite them to `YYYYMMDDNN`)
|
|
124
|
+
- For HA, point primary + secondary at both Authoritative nodes and use the same API key if your plugin config has a single key field
|
|
125
|
+
|
|
126
|
+
## Operations
|
|
127
|
+
|
|
128
|
+
- **Live Status**: server reachability, version, zone count, per-zone SOA parity (`in sync` / `drift` / `unreachable`)
|
|
129
|
+
- **Zone detail**: read-only list of active `netbox_dns` records + Sync now
|
|
130
|
+
- Edit records only under **Plugins → DNS**
|
|
131
|
+
|
|
132
|
+
### Troubleshooting
|
|
133
|
+
|
|
134
|
+
| Symptom | Likely cause |
|
|
135
|
+
|---------|----------------|
|
|
136
|
+
| `404` on `/servers/localhost/` | Trailing slash — fixed in recent releases; upgrade the plugin |
|
|
137
|
+
| Persistent SOA **drift** | Zone still has `SOA-EDIT-API=DEFAULT`; Sync with 0.1.2+ recreates with `NONE` |
|
|
138
|
+
| Connection timeout | Firewall / `webserver-allow-from` does not include NetBox |
|
|
139
|
+
|
|
140
|
+
## Development
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
python -m venv .venv && source .venv/bin/activate
|
|
144
|
+
pip install -e ".[dev]"
|
|
145
|
+
ruff check src tests
|
|
146
|
+
pytest -q
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Related projects
|
|
150
|
+
|
|
151
|
+
- [`netbox-plugin-dns`](https://github.com/sys4/netbox-plugin-dns) — DNS data model & IPAM DNSsync in NetBox
|
|
152
|
+
- [`netbox-opennebula-sync`](https://github.com/mael-chouteau/netbox-opennebula-sync) — OpenNebula → NetBox inventory sync
|
|
153
|
+
|
|
154
|
+
## License
|
|
155
|
+
|
|
156
|
+
Apache License 2.0 — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# netbox-pdns-connector
|
|
2
|
+
|
|
3
|
+
[](https://github.com/mael-chouteau/netbox-pdns-connector/actions/workflows/ci.yml)
|
|
4
|
+
[](https://pypi.org/project/netbox-pdns-connector/)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](https://github.com/netbox-community/netbox)
|
|
7
|
+
|
|
8
|
+
NetBox Community plugin that pushes **active** DNS zones and records from
|
|
9
|
+
[`netbox_dns`](https://github.com/sys4/netbox-plugin-dns) to one or two
|
|
10
|
+
**PowerDNS Authoritative** servers via the REST API v1.
|
|
11
|
+
|
|
12
|
+
This plugin is a **connector only**: it does **not** store zones or records.
|
|
13
|
+
Edit DNS data in **Plugins → DNS** (`netbox_dns`); this plugin syncs that data
|
|
14
|
+
to PowerDNS and shows live health / SOA serial parity.
|
|
15
|
+
|
|
16
|
+
Ideal for operators who already use NetBox + `netbox_dns` as the DNS source of
|
|
17
|
+
truth and want PowerDNS (single node or HA pair) as the serving plane.
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
| Area | What you get |
|
|
22
|
+
|------|----------------|
|
|
23
|
+
| **UI** | Plugins → PowerDNS → **Live Status** (API probe + zone SOA parity) + zone detail (read-only) + **Settings** |
|
|
24
|
+
| **Sync** | RQ job: *Sync now*, configurable interval, optional realtime on `netbox_dns` changes |
|
|
25
|
+
| **Targets** | Primary and optional secondary PowerDNS API URLs (shared API key supported) |
|
|
26
|
+
| **Push model** | Native zones; atomic RRset REPLACE; orphan RRset DELETE; `soa_edit_api=NONE` so NetBox owns SOA serials |
|
|
27
|
+
| **Safety** | Dry-run mode, Fernet-encrypted API key (Django `SECRET_KEY`), optional DNS view filter |
|
|
28
|
+
|
|
29
|
+
Compatible with **NetBox 4.2+** (tested on **4.7**). License: **Apache-2.0**.
|
|
30
|
+
|
|
31
|
+
## Screenshots
|
|
32
|
+
|
|
33
|
+
> Add screenshots of Live Status and Settings after first public release (optional).
|
|
34
|
+
|
|
35
|
+
## Requirements
|
|
36
|
+
|
|
37
|
+
- NetBox 4.2 or newer with **netbox-rq** running
|
|
38
|
+
- [`netbox-plugin-dns`](https://github.com/sys4/netbox-plugin-dns) installed and migrated
|
|
39
|
+
- PowerDNS Authoritative with **API** enabled (`api=yes`, `webserver=yes`)
|
|
40
|
+
- Python 3.11+
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
/opt/netbox/venv/bin/pip install netbox-pdns-connector
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Add to `/opt/netbox/local_requirements.txt` for upgrades:
|
|
49
|
+
|
|
50
|
+
```text
|
|
51
|
+
netbox-pdns-connector
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
In `configuration.py`:
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
PLUGINS = [
|
|
58
|
+
'netbox_dns',
|
|
59
|
+
'netbox_pdns_connector',
|
|
60
|
+
]
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
sudo -u netbox /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py migrate netbox_pdns_connector
|
|
65
|
+
sudo systemctl restart netbox netbox-rq
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
1. Open **Plugins → PowerDNS → Settings**
|
|
69
|
+
2. Set primary (and optional secondary) API base URL, e.g. `http://dns1.example:8081`
|
|
70
|
+
3. Paste the PowerDNS API key (stored encrypted)
|
|
71
|
+
4. Optionally restrict sync to one `netbox_dns` **View**
|
|
72
|
+
5. Save, then **Live Status → Sync now**
|
|
73
|
+
|
|
74
|
+
The client appends `/api/v1`. Do **not** put a trailing slash on `/servers/localhost`
|
|
75
|
+
paths (PowerDNS returns 404).
|
|
76
|
+
|
|
77
|
+
## Configuration reference
|
|
78
|
+
|
|
79
|
+
| Setting | Description |
|
|
80
|
+
|---------|-------------|
|
|
81
|
+
| Primary / secondary URL | PowerDNS REST base (`http://host:8081`) |
|
|
82
|
+
| Server id | PowerDNS API server name (usually `localhost`) |
|
|
83
|
+
| API key | Shared secret; Fernet-encrypted at rest |
|
|
84
|
+
| View | Limit sync to one `netbox_dns` view (empty = all) |
|
|
85
|
+
| Sync interval | Minutes between automatic RQ runs |
|
|
86
|
+
| Realtime sync | Enqueue sync on zone/record save/delete |
|
|
87
|
+
| Dry run | Compute push without calling PowerDNS |
|
|
88
|
+
|
|
89
|
+
### PowerDNS side tips
|
|
90
|
+
|
|
91
|
+
- Restrict `webserver-allow-from` to your NetBox host
|
|
92
|
+
- Firewall API port (e.g. 8081) accordingly
|
|
93
|
+
- Zones are created as **Native** with `soa_edit` / `soa_edit_api` = **NONE** so NetBox SOA serials are preserved (PowerDNS `DEFAULT` would rewrite them to `YYYYMMDDNN`)
|
|
94
|
+
- For HA, point primary + secondary at both Authoritative nodes and use the same API key if your plugin config has a single key field
|
|
95
|
+
|
|
96
|
+
## Operations
|
|
97
|
+
|
|
98
|
+
- **Live Status**: server reachability, version, zone count, per-zone SOA parity (`in sync` / `drift` / `unreachable`)
|
|
99
|
+
- **Zone detail**: read-only list of active `netbox_dns` records + Sync now
|
|
100
|
+
- Edit records only under **Plugins → DNS**
|
|
101
|
+
|
|
102
|
+
### Troubleshooting
|
|
103
|
+
|
|
104
|
+
| Symptom | Likely cause |
|
|
105
|
+
|---------|----------------|
|
|
106
|
+
| `404` on `/servers/localhost/` | Trailing slash — fixed in recent releases; upgrade the plugin |
|
|
107
|
+
| Persistent SOA **drift** | Zone still has `SOA-EDIT-API=DEFAULT`; Sync with 0.1.2+ recreates with `NONE` |
|
|
108
|
+
| Connection timeout | Firewall / `webserver-allow-from` does not include NetBox |
|
|
109
|
+
|
|
110
|
+
## Development
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
python -m venv .venv && source .venv/bin/activate
|
|
114
|
+
pip install -e ".[dev]"
|
|
115
|
+
ruff check src tests
|
|
116
|
+
pytest -q
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Related projects
|
|
120
|
+
|
|
121
|
+
- [`netbox-plugin-dns`](https://github.com/sys4/netbox-plugin-dns) — DNS data model & IPAM DNSsync in NetBox
|
|
122
|
+
- [`netbox-opennebula-sync`](https://github.com/mael-chouteau/netbox-opennebula-sync) — OpenNebula → NetBox inventory sync
|
|
123
|
+
|
|
124
|
+
## License
|
|
125
|
+
|
|
126
|
+
Apache License 2.0 — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "netbox-pdns-connector"
|
|
7
|
+
version = "0.1.2"
|
|
8
|
+
description = "NetBox plugin: push netbox_dns zones and records to PowerDNS Authoritative (REST API v1)"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "Apache-2.0" }
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
authors = [{ name = "NetBox PowerDNS Connector contributors" }]
|
|
13
|
+
keywords = ["netbox", "powerdns", "dns", "netbox_dns", "plugin", "ddi"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Framework :: Django",
|
|
17
|
+
"Intended Audience :: System Administrators",
|
|
18
|
+
"License :: OSI Approved :: Apache Software License",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Topic :: Internet :: Name Service (DNS)",
|
|
24
|
+
"Topic :: System :: Systems Administration",
|
|
25
|
+
]
|
|
26
|
+
dependencies = [
|
|
27
|
+
"httpx>=0.27",
|
|
28
|
+
"cryptography>=42.0",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
dev = ["pytest>=8.0", "ruff>=0.6"]
|
|
33
|
+
|
|
34
|
+
[project.urls]
|
|
35
|
+
Homepage = "https://github.com/mael-chouteau/netbox-pdns-connector"
|
|
36
|
+
Issues = "https://github.com/mael-chouteau/netbox-pdns-connector/issues"
|
|
37
|
+
Documentation = "https://github.com/mael-chouteau/netbox-pdns-connector#readme"
|
|
38
|
+
|
|
39
|
+
[tool.setuptools.packages.find]
|
|
40
|
+
where = ["src"]
|
|
41
|
+
|
|
42
|
+
[tool.setuptools.package-data]
|
|
43
|
+
netbox_pdns_connector = [
|
|
44
|
+
"templates/**/*.html",
|
|
45
|
+
"migrations/*.py",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[tool.pytest.ini_options]
|
|
49
|
+
testpaths = ["tests"]
|
|
50
|
+
pythonpath = ["src"]
|
|
51
|
+
|
|
52
|
+
[tool.ruff]
|
|
53
|
+
line-length = 100
|
|
54
|
+
target-version = "py311"
|
|
55
|
+
|
|
56
|
+
[tool.ruff.lint]
|
|
57
|
+
select = ["E", "F", "I", "UP", "B"]
|
|
58
|
+
[tool.ruff.lint.per-file-ignores]
|
|
59
|
+
"**/migrations/*.py" = ["E501"]
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Push netbox_dns zones and records to PowerDNS Authoritative API v1."""
|
|
2
|
+
|
|
3
|
+
__version__ = "0.1.2"
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
from netbox.plugins import PluginConfig
|
|
7
|
+
except ImportError: # Standalone / unit tests without NetBox
|
|
8
|
+
config = None
|
|
9
|
+
else:
|
|
10
|
+
|
|
11
|
+
class PowerDNSConnectorConfig(PluginConfig):
|
|
12
|
+
name = "netbox_pdns_connector"
|
|
13
|
+
verbose_name = "PowerDNS"
|
|
14
|
+
description = "Synchronize netbox_dns zones to PowerDNS Authoritative servers"
|
|
15
|
+
version = __version__
|
|
16
|
+
author = "NetBox PowerDNS Connector contributors"
|
|
17
|
+
author_email = "dev@localhost"
|
|
18
|
+
base_url = "powerdns"
|
|
19
|
+
min_version = "4.2"
|
|
20
|
+
default_settings = {}
|
|
21
|
+
required_settings = []
|
|
22
|
+
|
|
23
|
+
def ready(self):
|
|
24
|
+
super().ready()
|
|
25
|
+
from . import (
|
|
26
|
+
jobs, # noqa: F401
|
|
27
|
+
signals, # noqa: F401
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
config = PowerDNSConnectorConfig
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Encrypt plugin secrets with a Fernet key derived from Django SECRET_KEY."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import base64
|
|
6
|
+
import hashlib
|
|
7
|
+
|
|
8
|
+
from cryptography.fernet import Fernet, InvalidToken
|
|
9
|
+
from django.conf import settings
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _fernet() -> Fernet:
|
|
13
|
+
digest = hashlib.sha256(settings.SECRET_KEY.encode("utf-8")).digest()
|
|
14
|
+
return Fernet(base64.urlsafe_b64encode(digest))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def encrypt_secret(plaintext: str) -> str:
|
|
18
|
+
if not plaintext:
|
|
19
|
+
return ""
|
|
20
|
+
return _fernet().encrypt(plaintext.encode("utf-8")).decode("ascii")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def decrypt_secret(ciphertext: str) -> str:
|
|
24
|
+
if not ciphertext:
|
|
25
|
+
return ""
|
|
26
|
+
try:
|
|
27
|
+
return _fernet().decrypt(ciphertext.encode("ascii")).decode("utf-8")
|
|
28
|
+
except (InvalidToken, ValueError):
|
|
29
|
+
return ""
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from django import forms
|
|
2
|
+
from netbox_dns.models import View
|
|
3
|
+
from utilities.forms.fields import DynamicModelChoiceField
|
|
4
|
+
|
|
5
|
+
from .models import PowerDNSSyncConfig
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class PowerDNSSyncConfigForm(forms.ModelForm):
|
|
9
|
+
api_key = forms.CharField(
|
|
10
|
+
required=False,
|
|
11
|
+
widget=forms.PasswordInput(render_value=False, attrs={"placeholder": "••••••••"}),
|
|
12
|
+
label="PowerDNS API key",
|
|
13
|
+
help_text="Leave blank to keep the current secret",
|
|
14
|
+
)
|
|
15
|
+
sync_interval = forms.IntegerField(
|
|
16
|
+
min_value=1,
|
|
17
|
+
max_value=10080,
|
|
18
|
+
help_text="Minutes between automatic syncs (presets: 5 / 15 / 30 / 60)",
|
|
19
|
+
)
|
|
20
|
+
view = DynamicModelChoiceField(
|
|
21
|
+
queryset=View.objects.all(),
|
|
22
|
+
required=False,
|
|
23
|
+
label="DNS view filter",
|
|
24
|
+
help_text="Sync only zones in this view (empty = all views)",
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
class Meta:
|
|
28
|
+
model = PowerDNSSyncConfig
|
|
29
|
+
fields = (
|
|
30
|
+
"primary_url",
|
|
31
|
+
"secondary_url",
|
|
32
|
+
"server_id",
|
|
33
|
+
"view",
|
|
34
|
+
"sync_enabled",
|
|
35
|
+
"sync_interval",
|
|
36
|
+
"realtime_sync",
|
|
37
|
+
"dry_run",
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
def save(self, commit=True):
|
|
41
|
+
obj = super().save(commit=False)
|
|
42
|
+
api_key = self.cleaned_data.get("api_key")
|
|
43
|
+
if api_key:
|
|
44
|
+
obj.set_api_key(api_key)
|
|
45
|
+
if commit:
|
|
46
|
+
obj.save()
|
|
47
|
+
return obj
|