Compare commits

...
24 Commits
Author SHA1 Message Date
sven da6a5e09a5 modified: netbox_dns_bridge/__init__.py
Remove unneeded definition.

modified:   MANIFEST.in
Correct path

new file:   netbox_dns_bridge/migrations/__init__.py
Fixes missing migration.

new file:   netbox_dns_bridge/management/__init__.py
new file:   netbox_dns_bridge/management/commands/__init__.py
Just in case
2026-04-10 13:23:37 +02:00
Sven Luthi 3eb58f9b29 modified: docs/install-systemd-service.md
Correct naming in service unit
2026-04-10 11:16:58 +02:00
Sven Luthi ad52457c48 modified: README.md
Fix link alt text
2026-04-10 10:59:49 +02:00
Sven Luthi 9c3d7cce7e modified: README.md 2026-04-09 19:18:35 +02:00
Sven Luthi 6418ed56e6 modified: README.md 2026-04-09 19:10:39 +02:00
Sven Luthi fd16f7e701 modified: netbox_dns_bridge/__init__.py
Bump version to 1.5.2
2026-04-09 18:51:54 +02:00
Sven Luthi f926795d1b modified: netbox_dns_bridge/request_handler.py
Change query logging from debug to info. Seeing queries is very useful :)
2026-04-09 18:36:14 +02:00
Sven Luthi eedc01303b modified: netbox_dns_bridge/catalog_zone_manager.py
modified:   netbox_dns_bridge/request_handler.py
modified:   netbox_dns_bridge/utils.py
Various little bug fixes. Analysed by AI but fixed by hand to ensure integrity.
2026-04-09 18:28:05 +02:00
Sven Luthi 646059bb07 modified: netbox_dns_bridge/signals.py
Fix import path
2026-04-09 17:27:00 +02:00
Sven Luthi f41b4cea56 modified: netbox_dns_bridge/request_handler.py
Closes issue #15
2026-04-09 15:04:39 +02:00
Sven Luthi 3dec22b9f3 modified: README.md 2026-04-09 14:32:50 +02:00
Sven Luthi b23c773bee modified: README.md 2026-04-09 14:27:46 +02:00
Sven Luthi 53b12c9e15 modified: README.md - Improve post 1.0.7 upgrade guide.
modified:   pyproject.toml - Fix to licensing file reference.
2026-04-09 13:58:55 +02:00
Sven Luthi d56a8f9140 modified: README.md 2026-04-08 20:32:00 +02:00
Sven Luthi c32161b8a2 modified: netbox_dns_bridge/catalog_zone_manager.py
modified:   netbox_dns_bridge/dns_server.py
modified:   netbox_dns_bridge/management/commands/dns-export-zone.py
modified:   netbox_dns_bridge/management/commands/dns-export-zones.py
modified:   netbox_dns_bridge/management/commands/dns-settings.py
modified:   netbox_dns_bridge/management/commands/dns-transfer-endpoint.py
modified:   netbox_dns_bridge/migrations/0001_initial.py
modified:   netbox_dns_bridge/models.py
modified:   netbox_dns_bridge/request_handler.py
modified:   netbox_dns_bridge/signals.py
modified:   netbox_dns_bridge/utils.py
Black code formating corrected
2026-04-08 20:14:38 +02:00
Sven Luthi 165a0faa67 modified: docs/architecture-overview.drawio
modified:   docs/architecture-overview.svg
2026-04-08 20:09:46 +02:00
Sven Luthi 5a20737ba9 modified: README.md 2026-04-08 20:09:46 +02:00
sven f713719543 modified: pyproject.toml
Fix paths after restructuring

renamed:    netbox_dns_bridge/management/commands/export-dns-zone.py -> netbox_dns_bridge/management/commands/dns-export-zone.py
renamed:    netbox_dns_bridge/management/commands/export-all-dns-zones.py -> netbox_dns_bridge/management/commands/dns-export-zones.py
Unify command naming scheme

new file:   netbox_dns_bridge/migrations/0001_initial.py
Adds the missing migration. Since the plugin was renamed this is also an opportunity to merge all changes into a single migration.

renamed:    netbox_dns_bridge/service/transfer/catalog_zone_manager.py -> netbox_dns_bridge/catalog_zone_manager.py
renamed:    netbox_dns_bridge/service/transfer/dns_server.py -> netbox_dns_bridge/dns_server.py
new file:   netbox_dns_bridge/management/commands/dns-settings.py
modified:   netbox_dns_bridge/management/commands/dns-transfer-endpoint.py
renamed:    netbox_dns_bridge/service/transfer/request_handler.py -> netbox_dns_bridge/request_handler.py
deleted:    netbox_dns_bridge/service/transfer/__init__.py
Another restructure to simplify code re-use. New command dns-settings added to allow setting of catalog zone serial.
This will be needed to migrate from previous versions.
2026-04-08 20:09:13 +02:00
sven 5f48472ba4 modified: README.md 2026-04-08 18:58:49 +02:00
sven 79ae6c2068 modified: README.md
modified:   netbox_dns_bridge/__init__.py
modified:   CHANGELOG.md
Change versioning scheme to mach netbox-plugin-dns
2026-04-08 18:58:37 +02:00
Sven Luthi 756c491e28 Renaming Project and changing license 2026-04-08 10:24:24 +02:00
sven 4a1930a896 new file: CHANGELOG.md
modified:   README.md
2026-03-02 18:44:50 +01:00
Sven Luthi 5040ce70a0 modified: README.md
modified:   pyproject.toml
deleted:    requirements.txt
2026-02-18 16:59:37 +01:00
Sven Luthi 4d3b01127b Bump to v1.0.7 2026-02-18 15:51:55 +01:00
30 changed files with 452 additions and 668 deletions

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
src/netbox_plugin_bind_provisioner.egg-info netbox_dns_bridge.egg-info
dist/ dist/
build/ build/
__pycache__ __pycache__
+12
View File
@@ -0,0 +1,12 @@
## 1.0.7 - 2026-03-02
README Change - Moving private keys to global scope since Bind 9.20 view scoped keys have become unreliable and sometimes wouldnt match.
## 1.0.8 - 2026-03-12
- Change License to MIT to match the netbox-plugin-dns License. This project rests on the netbox-plugin-dns so a matching
license makes more sense.
- Renaming Project from Netbox Plugin Bind Provisioner to Netbox DNS Bridge as new code will be contributed that allows
data to flow in both directions (Dynamic Updates), not just out of Netbox DNS.
## 1.5.0 - 2026-04-08
- Change to versioning scheme - Now matches the major and minor version number to the one of netbox-plugin-dns. Only the minor sub version
will be used to track incremental changes to this plugin.
+14 -335
View File
@@ -1,339 +1,18 @@
GNU GENERAL PUBLIC LICENSE MIT License
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., Copyright (c) 2025-2026 Sven Luethi
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the “Software”), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The licenses for most software are designed to take away your The above copyright notice and this permission notice shall be included in all copies or substantial
freedom to share and change it. By contrast, the GNU General Public portions of the Software.
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
price. Our General Public Licenses are designed to make sure that you NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
have the freedom to distribute copies of free software (and charge for NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
this service if you wish), that you receive source code or can get it OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
if you want it, that you can change the software or use pieces of it CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
+1 -1
View File
@@ -1 +1 @@
recursive-include netbox_bind_provisioner *.py recursive-include netbox_dns_bridge *.py
+101 -61
View File
@@ -1,43 +1,49 @@
# Netbox Bind Provisioner # Netbox DNS Bridge
The Netbox Bind Provisioner plugin implements a lightweight DNS server inside (Formerly Netbox Bind Provisioner)
Netbox and builds a bridge for BIND and other DNS Servers implementing RFC9432
to retrieve DNS Zones directly from Netbox using DNS native mechanisms.
[![PyPi](https://img.shields.io/pypi/v/netbox-plugin-bind-provisioner)](https://pypi.org/project/netbox-plugin-bind-provisioner/) The NetBox DNS Bridge plugin extends [NetBox DNS](https://github.com/sys4/netbox-plugin-dns) by
[![Stars Badge](https://img.shields.io/github/stars/suraxius/netbox-plugin-bind-provisioner?style=flat)](https://github.com/suraxius/netbox-plugin-bind-provisioner/stargazers) embedding a lightweight DNS server directly within NetBox. It acts as a bridge between NetBox DNS
[![Forks Badge](https://img.shields.io/github/forks/suraxius/netbox-plugin-bind-provisioner?style=flat)](https://github.com/suraxius/netbox-plugin-bind-provisioner/network/members) and your existing DNS infrastructure, leveraging native DNS mechanisms for seamless integration.
[![Issues Badge](https://img.shields.io/github/issues/suraxius/netbox-plugin-bind-provisioner)](https://github.com/suraxius/netbox-plugin-bind-provisioner/issues) These include zone transfers (RFC 5936), catalog zones (RFC 9432), and dynamic updates (RFC 2136).
[![Pull Requests Badge](https://img.shields.io/github/issues-pr/suraxius/netbox-plugin-bind-provisioner)](https://github.com/suraxius/netbox-plugin-bind-provisioner/pulls)
[![GitHub contributors](https://img.shields.io/github/contributors/suraxius/netbox-plugin-bind-provisioner?color=2b9348)](https://github.com/suraxius/netbox-plugin-bind-provisioner/graphs/contributors) <a href="https://pypi.org/project/netbox-plugin-dns-bridge/"><img src="https://img.shields.io/pypi/v/netbox-plugin-dns-bridge" alt="PyPi"></a>
[![License Badge](https://img.shields.io/github/license/suraxius/netbox-plugin-bind-provisioner?color=2b9348)](https://github.com/suraxius/netbox-plugin-bind-provisioner/blob/master/LICENSE) <a href="https://github.com/suraxius/netbox-plugin-dns-bridge/stargazers"><img src="https://img.shields.io/github/stars/suraxius/netbox-plugin-dns-bridge?style=flat" alt="Stars Badge"></a>
[![Code Style Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) <a href="https://github.com/suraxius/netbox-plugin-dns-bridge/network/members"><img src="https://img.shields.io/github/forks/suraxius/netbox-plugin-dns-bridge?style=flat" alt="Forks Badge"></a>
[![Downloads](https://static.pepy.tech/personalized-badge/netbox-plugin-bind-provisioner?period=total&left_color=BLACK&right_color=BLUE&left_text=Downloads)](https://pepy.tech/project/netbox-plugin-bind-provisioner) <a href="https://github.com/suraxius/netbox-plugin-dns-bridge/issues"><img src="https://img.shields.io/github/issues/suraxius/netbox-plugin-dns-bridge" alt="Issues Badge"></a>
[![Downloads/Week](https://static.pepy.tech/personalized-badge/netbox-plugin-bind-provisioner?period=monthly&left_color=BLACK&right_color=BLUE&left_text=Downloads%2fMonth)](https://pepy.tech/project/netbox-plugin-bind-provisioner) <a href="https://github.com/suraxius/netbox-plugin-dns-bridge/pulls"><img src="https://img.shields.io/github/issues-pr/suraxius/netbox-plugin-dns-bridge" alt="Pull Requests Badge"></a>
[![Downloads/Month](https://static.pepy.tech/personalized-badge/netbox-plugin-bind-provisioner?period=weekly&left_color=BLACK&right_color=BLUE&left_text=Downloads%2fWeek)](https://pepy.tech/project/netbox-plugin-bind-provisioner) <a href="https://github.com/suraxius/netbox-plugin-dns-bridge/graphs/contributors"><img src="https://img.shields.io/github/contributors/suraxius/netbox-plugin-dns-bridge?color=2b9348" alt="GitHub contributors"></a>
<a href="https://github.com/suraxius/netbox-plugin-dns-bridge/blob/master/LICENSE"><img src="https://img.shields.io/github/license/suraxius/netbox-plugin-dns-bridge?color=2b9348" alt="License Badge"></a>
<a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Code Style Black"></a>
<a href="https://pepy.tech/project/netbox-plugin-dns-bridge"><img src="https://static.pepy.tech/personalized-badge/netbox-plugin-dns-bridge?period=total&left_color=BLACK&right_color=BLUE&left_text=Downloads" alt="Downloads"></a>
<a href="https://pepy.tech/project/netbox-plugin-dns-bridge"><img src="https://static.pepy.tech/personalized-badge/netbox-plugin-dns-bridge?period=monthly&left_color=BLACK&right_color=BLUE&left_text=Downloads%2fMonth" alt="Downloads/Month"></a>
<a href="https://pepy.tech/project/netbox-plugin-dns-bridge"><img src="https://static.pepy.tech/personalized-badge/netbox-plugin-dns-bridge?period=weekly&left_color=BLACK&right_color=BLUE&left_text=Downloads%2fWeek" alt="Downloads/Week"></a>
![Architecture Overview](docs/architecture-overview.svg)
DISCLAIMER: The dynamic update endpoint isn't here yet. Its planned - without a deadline.
## Plugin configuration ## Plugin configuration
While providing Zone transfers via AXFR, the Server also exposes specialized While providing Zone transfers via AXFR, the Server also exposes specialized catalog zones that BIND
catalog zones that BIND and other RFC9432 compliant DNS Servers use to and other RFC9432 compliant DNS Servers use to automatically discover newly created zones and remove
automatically discover newly created zones and remove deleted ones. The plugin deleted ones. The plugin supports views and basic DNS security via TSIG.
supports views and basic DNS security via TSIG.
The plugin exposes one catalog zone per view. Each catalog zone is made available The plugin exposes one catalog zone per view. Each catalog zone is made available under the special
under the special zone name **"catz"** and addtionally under **"[viewname].catz"** zone name **"catz"** and addtionally under **"[viewname].catz"** and may be queried through the
and may be queried through the built-in DNS server just like any other dns zone. built-in DNS server just like any other dns zone.
For proper operation, each view requires an installed TSIG key, and the For proper operation, each view requires an installed TSIG key, and the `dns-transfer-endpoint` must
`dns-transfer-endpoint` must be running as a separate background service using be running as a separate background service using the `manage.py` command. Note that DNSSEC support
the `manage.py` command. Note that DNSSEC support will be added once BIND9 will be added once BIND9 provides a mechanism to configure it through the Catalog Zones system.
provides a mechanism to configure it through the Catalog Zones system.
To start the service in the foreground: To start the transfer endpoint service in the foreground:
``` ```
manage.py dns-transfer-endpoint --port 5354 manage.py dns-transfer-endpoint --port 5354
``` ```
This process needs to be scheduled as a background service for the built-in DNS This process needs to be scheduled as a background service for the built-in DNS Server to work
Server to work correctly. For Linux users with Systemd (Ubuntu, etc), Matt Kollross correctly. For Linux users with Systemd (Ubuntu, etc), Matt Kollross provides a startup unit and
provides a startup unit and instructions [here](docs/install-systemd-service.md). instructions [here](docs/install-systemd-service.md).
### Service parameters ### Service parameters
Parameter | Description Parameter | Description
@@ -50,11 +56,45 @@ Setting | Description
--------------------| --------------------------------------------------------- --------------------| ---------------------------------------------------------
tsig_keys | Maps a TSIG Key to be used for each view. tsig_keys | Maps a TSIG Key to be used for each view.
## Plugin compatibility
This plugin is an extension to the netbox-plugin-dns plugin. As such the versioning of this plugin
was changed to match the one of the netbox-plugin-dns plugin closely. To guarantee compatability,
ensure that the major and minor version match between both plugins.
For example, when using netbox-plugin-dns `v1.5.5` install netbox-plugin-dns-bridge `v1.5.x`.
## Post 1.0.7 Upgrade Guide
Applies only if you have a <= 1.0.7 installation. If you are freshly installing this plugin,
go on to [Installation Guide](#installation-guide).
After version 1.0.7, the project was restructured and renamed. Until that point version updates
happened more or less automatically. However, this shift is more of a move from one plugin to
another as the package name has changed.
This should not be an issue since the slave DNS Servers connected to Netbox can operate
independently while this plugin is being upgraded.
Make sure to note down the catalog zone serial number before going further.
1. Remove Netbox Bind Provisioner package
- Remove `netbox-plugin-bind-provisioner` from **local_dependencies.txt**
- Uninstall the package: `pip uninstall netbox-plugin-bind-provisioner`
2. Install Netbox DNS Bridge package
- Install the package `pip install netbox-plugin-dns-bridge`
- Put `netbox-plugin-dns-bridge` in your **local_dependencies.txt** so it will be installed on
next upgrade.
3. Adjust your `configuration.py`
- Change the plugin name from `netbox-plugin-bind-provisioner` to `netbox-plugin-dns-bridge`
- Change the key in `PLUGIN_CONFIG` from `netbox_plugin_bind_provisioner` to `netbox_dns_bridge`
4. Run migrations: `manage.py migrate`
5. Restore the catalog zone serial you noted down previously so that your slave dns servers continue
to pull the changes: `manage.py dns-settings set catalog-zone-soa-serial yourserialnumber`
6. Start the `dns-transfer-endpoint` service.
7. Mission accomplished.
## Installation guide ## Installation guide
This setup provisions a BIND9 server directly with DNS data from NetBox. This setup provisions a BIND9 server directly with DNS data from NetBox. BIND9 can optionally run on
BIND9 can optionally run on a separate server. If so, any reference to a separate server. If so, any reference to 127.0.0.1 in step 6 must be replaced with the IP address
127.0.0.1 in step 6 must be replaced with the IP address of the NetBox host. of the NetBox host. TCP and UDP traffic from the BIND9 server to the NetBox host must be allowed on
TCP and UDP traffic from the BIND9 server to the NetBox host must be allowed on
port 5354 (or the port you have configured). port 5354 (or the port you have configured).
This guide assumes: This guide assumes:
@@ -72,7 +112,7 @@ This guide assumes:
2. Adding required package 2. Adding required package
``` ```
cd netbox cd netbox
echo netbox-plugin-bind-provisioner >> local_requirements.txt echo netbox-plugin-dns-bridge >> local_requirements.txt
. venv/bin/activate . venv/bin/activate
pip install -r local_requirements.txt pip install -r local_requirements.txt
``` ```
@@ -84,10 +124,10 @@ This guide assumes:
``` ```
to to
``` ```
PLUGINS = ['netbox_dns', 'netbox_plugin_bind_provisioner'] PLUGINS = ['netbox_dns', 'netbox_dns_bridge']
``` ```
Configure the Bind Exporter Plugin using the PLUGINS_CONFIG dictionary. Configure the DNS Bridge Plugin using the PLUGINS_CONFIG dictionary.
Change Change
``` ```
PLUGINS_CONFIG = {} PLUGINS_CONFIG = {}
@@ -95,7 +135,7 @@ This guide assumes:
to to
``` ```
PLUGINS_CONFIG = { PLUGINS_CONFIG = {
"netbox_plugin_bind_provisioner": { "netbox_dns_bridge": {
"tsig_keys": { "tsig_keys": {
"public": { "public": {
"keyname": "public_view_key", "keyname": "public_view_key",
@@ -114,34 +154,31 @@ This guide assumes:
Note that the tsig-key attributes keyname, algorithm and secret form a Note that the tsig-key attributes keyname, algorithm and secret form a
dictionary in following python structure path: dictionary in following python structure path:
``` ```
PLUGINS_CONFIG.netbox_plugin_bind_provisioner.tsig_keys.<dns_view_name> PLUGINS_CONFIG.netbox_dns_bridge.tsig_keys.<dns_view_name>
``` ```
This allows the plugin to map requests to the right dns view using the tsig This allows the plugin to map requests to the right dns view using the tsig
signature from each request. signature from each request.
4. Run migrations 4. Run migrations
``` ```
python3 netbox/manage.py migrate manage.py migrate
``` ```
5. Start listener 5. Start listener
This step runs the DNS endpoint used by bind to configure itself. You may want This step runs the DNS endpoint used by bind to configure itself. You may want to write a
to write a service wrapper that runs this in the background. service wrapper that runs this in the background. A guide for setting up a systemd service on
A guide for setting up a systemd service on Ubuntu is provided by Matt Ubuntu is provided by Matt Kollross [here](docs/install-systemd-service.md). Dont forget to
Kollross [here](docs/install-systemd-service.md). Dont forget to activate activate the venv if you do decide to run this service in the background.
the venv if you do decide to run this service in the background.
Note that `--port 5354` is optional. The listener will bind this port Note that `--port 5354` is optional. The listener will bind this port by default.
by default.
``` ```
python3 netbox/manage.py dns-transfer-endpoint --port 5354 manage.py dns-transfer-endpoint --port 5354
``` ```
6. Configuring a Bind9 to interact with Netbox via the dns-transfer-endpoint 6. Configuring a Bind9 to interact with Netbox via the dns-transfer-endpoint endpoint. Note that its
endpoint. Note that its not possible to give all the correct details of the not possible to give all the correct details of the `options` block as it is heavily dependent
`options` block as it is heavily dependent on the Operating System used. on the Operating System used. Please dont forget to adjust as required.
Please dont forget to adjust as required.
``` ```
########## OPTIONS ########## ########## OPTIONS ##########
@@ -169,14 +206,21 @@ This guide assumes:
192.168.0.0/16; 192.168.0.0/16;
}; };
########## ZONES ########## ######## TSIG Keys ########
view "public" {
key "public_view_key" { key "public_view_key" {
algorithm hmac-sha256; algorithm hmac-sha256;
secret "base64-encoded-secret"; secret "base64-encoded-secret";
}; };
key "private_view_key" {
algorithm hmac-sha256;
secret "base64-encoded-secret";
};
###########################
########## ZONES ##########
view "public" {
match-clients { public; }; match-clients { public; };
catalog-zones { catalog-zones {
@@ -195,11 +239,6 @@ This guide assumes:
}; };
view "private" { view "private" {
key "private_view_key" {
algorithm hmac-sha256;
secret "base64-encoded-secret";
};
match-clients { private; }; match-clients { private; };
catalog-zones { catalog-zones {
@@ -220,3 +259,4 @@ This guide assumes:
7. Restart bind - Done 7. Restart bind - Done
+76
View File
@@ -0,0 +1,76 @@
<mxfile host="Electron" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/29.0.3 Chrome/140.0.7339.249 Electron/38.7.0 Safari/537.36" version="29.0.3">
<diagram name="Page-1" id="inkmD5hxPkRoHiEHOzAS">
<mxGraphModel dx="831" dy="2028" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="WlUYMBEI5UY_wtPVGHlU-24" value="" style="whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
<mxGeometry x="560" y="457.5" width="80" height="80" as="geometry" />
</mxCell>
<mxCell id="WlUYMBEI5UY_wtPVGHlU-13" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f5f5f5;fontColor=#333333;strokeColor=#666666;" parent="1" vertex="1">
<mxGeometry x="70" y="210" width="600" height="220" as="geometry" />
</mxCell>
<mxCell id="WlUYMBEI5UY_wtPVGHlU-12" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" parent="1" vertex="1">
<mxGeometry x="430" y="260" width="230" height="150" as="geometry" />
</mxCell>
<mxCell id="WlUYMBEI5UY_wtPVGHlU-3" value="&lt;font style=&quot;font-size: 18px;&quot;&gt;Netbox&lt;/font&gt;" style="text;html=1;whiteSpace=wrap;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;rounded=0;" parent="1" vertex="1">
<mxGeometry x="80" y="220" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="WlUYMBEI5UY_wtPVGHlU-4" value="DNS" style="whiteSpace=wrap;html=1;aspect=fixed;fillColor=#dae8fc;strokeColor=#6c8ebf;rounded=1;" parent="1" vertex="1">
<mxGeometry x="300" y="260" width="100" height="100" as="geometry" />
</mxCell>
<mxCell id="WlUYMBEI5UY_wtPVGHlU-6" value="IPAM" style="whiteSpace=wrap;html=1;aspect=fixed;fillColor=#f8cecc;strokeColor=#b85450;gradientColor=none;rounded=1;" parent="1" vertex="1">
<mxGeometry x="80" y="260" width="100" height="100" as="geometry" />
</mxCell>
<mxCell id="WlUYMBEI5UY_wtPVGHlU-7" value="DHCP&lt;br&gt;(WIP)" style="whiteSpace=wrap;html=1;aspect=fixed;fillColor=#fff2cc;strokeColor=#d6b656;rounded=1;" parent="1" vertex="1">
<mxGeometry x="190" y="260" width="100" height="100" as="geometry" />
</mxCell>
<mxCell id="MSiTSJWh-g0ETCA7Z0x5-4" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="WlUYMBEI5UY_wtPVGHlU-9" target="WlUYMBEI5UY_wtPVGHlU-4">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="WlUYMBEI5UY_wtPVGHlU-9" value="Transfer&lt;br&gt;Endpoint" style="whiteSpace=wrap;html=1;aspect=fixed;fillColor=#d5e8d4;strokeColor=#82b366;rounded=1;" parent="1" vertex="1">
<mxGeometry x="440" y="300" width="100" height="100" as="geometry" />
</mxCell>
<mxCell id="WlUYMBEI5UY_wtPVGHlU-10" value="Dynamic Update&lt;br&gt;Endpoint" style="whiteSpace=wrap;html=1;aspect=fixed;fillColor=#d5e8d4;strokeColor=#82b366;rounded=1;" parent="1" vertex="1">
<mxGeometry x="550" y="300" width="100" height="100" as="geometry" />
</mxCell>
<mxCell id="WlUYMBEI5UY_wtPVGHlU-11" value="DNS Bridge" style="text;html=1;whiteSpace=wrap;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;rounded=0;" parent="1" vertex="1">
<mxGeometry x="440" y="270" width="90" height="30" as="geometry" />
</mxCell>
<mxCell id="WlUYMBEI5UY_wtPVGHlU-18" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=none;endFill=0;startArrow=classic;startFill=1;" parent="1" source="WlUYMBEI5UY_wtPVGHlU-16" target="WlUYMBEI5UY_wtPVGHlU-9" edge="1">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="490" y="450" />
<mxPoint x="490" y="450" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="WlUYMBEI5UY_wtPVGHlU-27" value="AXFR" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" parent="WlUYMBEI5UY_wtPVGHlU-18" connectable="0" vertex="1">
<mxGeometry x="-0.2264" y="2" relative="1" as="geometry">
<mxPoint x="2" y="5" as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="WlUYMBEI5UY_wtPVGHlU-16" value="" style="whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
<mxGeometry x="440" y="457.5" width="80" height="80" as="geometry" />
</mxCell>
<mxCell id="WlUYMBEI5UY_wtPVGHlU-20" value="" style="whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
<mxGeometry x="450" y="467.5" width="80" height="80" as="geometry" />
</mxCell>
<mxCell id="WlUYMBEI5UY_wtPVGHlU-19" value="DNS Server&lt;br&gt;(RFC9432)" style="whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
<mxGeometry x="460" y="477.5" width="80" height="80" as="geometry" />
</mxCell>
<mxCell id="WlUYMBEI5UY_wtPVGHlU-23" value="" style="whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
<mxGeometry x="570" y="467.5" width="80" height="80" as="geometry" />
</mxCell>
<mxCell id="WlUYMBEI5UY_wtPVGHlU-25" value="Client&lt;br&gt;(RFC2136)" style="whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
<mxGeometry x="580" y="477.5" width="80" height="80" as="geometry" />
</mxCell>
<mxCell id="MSiTSJWh-g0ETCA7Z0x5-3" value="Update" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="WlUYMBEI5UY_wtPVGHlU-24" target="WlUYMBEI5UY_wtPVGHlU-10">
<mxGeometry x="-0.3913" relative="1" as="geometry">
<mxPoint y="1" as="offset" />
</mxGeometry>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Do not edit this file with editors other than draw.io -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" style="background: #ffffff; background-color: light-dark(#ffffff, var(--ge-dark-color, #121212)); color-scheme: light dark;" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="601px" height="349px" viewBox="0 0 601 349" content="&lt;mxfile host=&quot;Electron&quot; agent=&quot;Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/29.0.3 Chrome/140.0.7339.249 Electron/38.7.0 Safari/537.36&quot; version=&quot;29.0.3&quot; scale=&quot;1&quot; border=&quot;0&quot;&gt;&#10; &lt;diagram name=&quot;Page-1&quot; id=&quot;inkmD5hxPkRoHiEHOzAS&quot;&gt;&#10; &lt;mxGraphModel dx=&quot;706&quot; dy=&quot;1724&quot; grid=&quot;1&quot; gridSize=&quot;10&quot; guides=&quot;1&quot; tooltips=&quot;1&quot; connect=&quot;1&quot; arrows=&quot;1&quot; fold=&quot;1&quot; page=&quot;1&quot; pageScale=&quot;1&quot; pageWidth=&quot;850&quot; pageHeight=&quot;1100&quot; math=&quot;0&quot; shadow=&quot;0&quot;&gt;&#10; &lt;root&gt;&#10; &lt;mxCell id=&quot;0&quot; /&gt;&#10; &lt;mxCell id=&quot;1&quot; parent=&quot;0&quot; /&gt;&#10; &lt;mxCell id=&quot;WlUYMBEI5UY_wtPVGHlU-24&quot; value=&quot;&quot; style=&quot;whiteSpace=wrap;html=1;aspect=fixed;&quot; parent=&quot;1&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry x=&quot;560&quot; y=&quot;457.5&quot; width=&quot;80&quot; height=&quot;80&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;WlUYMBEI5UY_wtPVGHlU-13&quot; value=&quot;&quot; style=&quot;rounded=0;whiteSpace=wrap;html=1;fillColor=#f5f5f5;fontColor=#333333;strokeColor=#666666;&quot; parent=&quot;1&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry x=&quot;70&quot; y=&quot;210&quot; width=&quot;600&quot; height=&quot;220&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;WlUYMBEI5UY_wtPVGHlU-12&quot; value=&quot;&quot; style=&quot;rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;&quot; parent=&quot;1&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry x=&quot;430&quot; y=&quot;260&quot; width=&quot;230&quot; height=&quot;150&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;WlUYMBEI5UY_wtPVGHlU-3&quot; value=&quot;&amp;lt;font style=&amp;quot;font-size: 18px;&amp;quot;&amp;gt;Netbox&amp;lt;/font&amp;gt;&quot; style=&quot;text;html=1;whiteSpace=wrap;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;rounded=0;&quot; parent=&quot;1&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry x=&quot;80&quot; y=&quot;220&quot; width=&quot;60&quot; height=&quot;30&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;WlUYMBEI5UY_wtPVGHlU-4&quot; value=&quot;DNS&quot; style=&quot;whiteSpace=wrap;html=1;aspect=fixed;fillColor=#dae8fc;strokeColor=#6c8ebf;rounded=1;&quot; parent=&quot;1&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry x=&quot;300&quot; y=&quot;260&quot; width=&quot;100&quot; height=&quot;100&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;WlUYMBEI5UY_wtPVGHlU-6&quot; value=&quot;IPAM&quot; style=&quot;whiteSpace=wrap;html=1;aspect=fixed;fillColor=#f8cecc;strokeColor=#b85450;gradientColor=none;rounded=1;&quot; parent=&quot;1&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry x=&quot;80&quot; y=&quot;260&quot; width=&quot;100&quot; height=&quot;100&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;WlUYMBEI5UY_wtPVGHlU-7&quot; value=&quot;DHCP&amp;lt;br&amp;gt;(WIP)&quot; style=&quot;whiteSpace=wrap;html=1;aspect=fixed;fillColor=#fff2cc;strokeColor=#d6b656;rounded=1;&quot; parent=&quot;1&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry x=&quot;190&quot; y=&quot;260&quot; width=&quot;100&quot; height=&quot;100&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;MSiTSJWh-g0ETCA7Z0x5-4&quot; style=&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;&quot; parent=&quot;1&quot; source=&quot;WlUYMBEI5UY_wtPVGHlU-9&quot; target=&quot;WlUYMBEI5UY_wtPVGHlU-4&quot; edge=&quot;1&quot;&gt;&#10; &lt;mxGeometry relative=&quot;1&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;WlUYMBEI5UY_wtPVGHlU-9&quot; value=&quot;Transfer&amp;lt;br&amp;gt;Endpoint&quot; style=&quot;whiteSpace=wrap;html=1;aspect=fixed;fillColor=#d5e8d4;strokeColor=#82b366;rounded=1;&quot; parent=&quot;1&quot; vertex=&quot;1&quot;&gt;&#10; &lt;mxGeometry x=&quot;440&quot; y=&quot;300&quot; width=&quot;100&quot; height=&quot;100&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;WlUYMBEI5UY_wtPVGHlU-10&quot; value=&quot;Dynamic Update&amp;lt;br&amp;gt;Endpoint&quot; style=&quot;whiteSpace=wrap;html=1;aspect=fixedLine truncated

After

Width:  |  Height:  |  Size: 112 KiB

+7 -7
View File
@@ -1,9 +1,9 @@
1. Create System Unit file 1. Create System Unit file
``` ```
cat <<EOF > /etc/systemd/system/netbox-bind-endpoint.service cat <<EOF > /etc/systemd/system/netbox-dns-endpoint.service
[Unit] [Unit]
Description=Netbox BIND Catalog Endpoing Description=Netbox DNS transfer endpoint
Documentation=https://github.com/Suraxius/netbox-plugin-bind-provisioner Documentation=https://github.com/Suraxius/netbox-plugin-dns-bridge
After=network-online.target After=network-online.target
Wants=network-online.target Wants=network-online.target
@@ -15,7 +15,7 @@
PIDFile=/var/tmp/netbox.pid PIDFile=/var/tmp/netbox.pid
WorkingDirectory=/opt/netbox WorkingDirectory=/opt/netbox
ExecStart=/opt/netbox/venv/bin/python3 /opt/netbox/netbox/manage.py dns-transfer-endpoint --port 5354 ExecStart=/opt/netbox/venv/bin/python3 /opt/netbox/netbox/manage.py dns-transfer-endpoint --address 0.0.0.0 --port 5354
Restart=on-failure Restart=on-failure
RestartSec=30 RestartSec=30
@@ -28,7 +28,7 @@
2. Enable and start the service 2. Enable and start the service
``` ```
systemctl enable netbox-bind-endpoint systemctl enable netbox-dns-endpoint
systemctl start netbox-bind-endpoint systemctl start netbox-dns-endpoint
systemctl status netbox-bind-endpoint systemctl status netbox-dns-endpoint
``` ```
@@ -2,7 +2,7 @@ import logging
from netbox.plugins import PluginConfig from netbox.plugins import PluginConfig
from django.conf import settings from django.conf import settings
__version__ = "1.0.6" __version__ = "1.5.3"
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -13,14 +13,14 @@ logging.basicConfig(
) )
class BindProvisionerConfig(PluginConfig): class DNSBridgeConfig(PluginConfig):
name = "netbox_plugin_bind_provisioner" name = "netbox_dns_bridge"
verbose_name = "Netbox Bind Provisioner" verbose_name = "Netbox DNS Bridge"
description = "Provisions Zones to a Bind Server configured as hidden master" description = ""
version = __version__ version = __version__
author = "Sven Luethi" author = "Sven Luethi"
author_email = "sven.luethi@everyware.ch" author_email = "dev@sven.luethi.co"
base_url = "bind_provisioner" base_url = "dns-bridge"
def ready(self): def ready(self):
self.settings = settings.PLUGINS_CONFIG.get(self.name, None) self.settings = settings.PLUGINS_CONFIG.get(self.name, None)
@@ -32,5 +32,4 @@ class BindProvisionerConfig(PluginConfig):
from . import signals as signals from . import signals as signals
config = BindProvisionerConfig config = DNSBridgeConfig
default_app_config = ".apps.NetboxBindProvisionerConfig"
@@ -12,30 +12,30 @@ import dns.exception
import dns.renderer import dns.renderer
from netbox_dns.models import Zone from netbox_dns.models import Zone
from netbox_dns.choices import ZoneStatusChoices from netbox_dns.choices import ZoneStatusChoices
from netbox_plugin_bind_provisioner.models import IntegerKeyValueSetting, CatalogZoneMemberIdentifier from netbox_dns_bridge.models import IntegerKeyValueSetting, CatalogZoneMemberIdentifier
from uuid import uuid4 from uuid import uuid4
from base64 import b32encode from base64 import b32encode
logger = logging.getLogger("dns-transfer-endpoint") logger = logging.getLogger(__name__)
_LOCK = threading.Lock() _LOCK = threading.Lock()
_SERIAL_MAX = 0xFFFFFFFF _SERIAL_MAX = 0xFFFFFFFF
_SERIAL_OBJ = None _SERIAL_OBJ = None
_PREVIOUS_LAST_ZONE_UPDATE = None _PREVIOUS_LAST_ZONE_UPDATE = None
def init() -> None: def init() -> None:
_init_serial() _init_serial()
_create_missing_member_identifiers() _create_missing_member_identifiers()
# Following function loads the last serial from the DB. No return value # Following function loads the last serial from the DB. No return value
# but it sets the setting "catalog_serial" or terminates the plugin on failure. # but it sets the setting "catalog_serial" or terminates the plugin on failure.
def _init_serial() -> None: def _init_serial() -> None:
global _SERIAL_OBJ global _SERIAL_OBJ
try: try:
_SERIAL_OBJ = IntegerKeyValueSetting.objects.get( _SERIAL_OBJ = IntegerKeyValueSetting.objects.get(key="catalog-zone-soa-serial")
key="catalog-zone-soa-serial"
)
logger.debug( logger.debug(
f"Catalog zone SOA serial number {_SERIAL_OBJ.value} loaded from database" f"Catalog zone SOA serial number {_SERIAL_OBJ.value} loaded from database"
) )
@@ -47,21 +47,26 @@ def _init_serial() -> None:
f"Catalog zone SOA serial number was not set in the database. Set to {_SERIAL_OBJ.value}" f"Catalog zone SOA serial number was not set in the database. Set to {_SERIAL_OBJ.value}"
) )
def _increment_serial() -> None:
def _set_serial(new_serial: int) -> bool:
global _SERIAL_OBJ global _SERIAL_OBJ
if 0 < _SERIAL_OBJ.value < _SERIAL_MAX: if 0 < new_serial < _SERIAL_MAX:
_SERIAL_OBJ.value += 1 _SERIAL_OBJ.value = new_serial
_SERIAL_OBJ.save() _SERIAL_OBJ.save()
return True
else: else:
return False
def _increment_serial() -> None:
if not _set_serial(_SERIAL_OBJ.value + 1):
logger.warning( logger.warning(
f"Failed to incremenet catalog serial {_SERIAL_OBJ.value}. Will overflow serial back to 1" f"Catalog serial {_SERIAL_OBJ.value} reached max — wrapping back to 1"
)
_SERIAL_OBJ.value = 1
_SERIAL_OBJ.save()
logger.debug(
f"Catalog zone SOA serial number incremented to {_SERIAL_OBJ.value}"
) )
_set_serial(1)
logger.debug(f"Catalog zone SOA serial number is now {_SERIAL_OBJ.value}")
# If a zone has no catz identifier yet, create it: # If a zone has no catz identifier yet, create it:
def _create_missing_member_identifiers() -> None: def _create_missing_member_identifiers() -> None:
@@ -80,7 +85,9 @@ def _create_missing_member_identifiers() -> None:
] ]
for identifier in new_objects: for identifier in new_objects:
logger.debug(f"Zone {identifier.zone} has no catz member identifier. Creating...") logger.debug(
f"Zone {identifier.zone} has no catz member identifier. Creating..."
)
CatalogZoneMemberIdentifier.objects.bulk_create( CatalogZoneMemberIdentifier.objects.bulk_create(
new_objects, new_objects,
@@ -130,7 +137,7 @@ def create_zone(name, view_name) -> dns.zone.Zone:
qname = dns.name.from_text(nb_zone.name, dns.name.root) qname = dns.name.from_text(nb_zone.name, dns.name.root)
# Create PTR record # Create PTR record
#p_name = f"zid-{nb_zone.id:09d}" # p_name = f"zid-{nb_zone.id:09d}"
p_name = nb_zone.catz_identifier.name p_name = nb_zone.catz_identifier.name
ptr_name = dns.name.from_text(p_name, ptr_base) ptr_name = dns.name.from_text(p_name, ptr_base)
@@ -192,9 +199,7 @@ def create_zone(name, view_name) -> dns.zone.Zone:
# NS record for catz. # NS record for catz.
ns_name = dns.name.from_text("invalid", dns.name.root) ns_name = dns.name.from_text("invalid", dns.name.root)
ns_rdata = dns.rdata.from_text( ns_rdata = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.NS, str(ns_name))
dns.rdataclass.IN, dns.rdatatype.NS, str(ns_name)
)
ns_rdataset = dns.rdataset.Rdataset(dns.rdataclass.IN, dns.rdatatype.NS) ns_rdataset = dns.rdataset.Rdataset(dns.rdataclass.IN, dns.rdatatype.NS)
ns_rdataset.add(ns_rdata, 0) ns_rdataset.add(ns_rdata, 0)
@@ -203,9 +208,7 @@ def create_zone(name, view_name) -> dns.zone.Zone:
ns_node.rdatasets.append(ns_rdataset) ns_node.rdatasets.append(ns_rdataset)
# TXT record for version.catz. # TXT record for version.catz.
version_name = dns.name.from_text( version_name = dns.name.from_text("version", origin) # relative to origin "catz."
"version", origin
) # relative to origin "catz."
txt_rdata = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.TXT, '"2"') txt_rdata = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.TXT, '"2"')
txt_rdataset = dns.rdataset.Rdataset(dns.rdataclass.IN, dns.rdatatype.TXT) txt_rdataset = dns.rdataset.Rdataset(dns.rdataclass.IN, dns.rdatatype.TXT)
@@ -217,11 +220,13 @@ def create_zone(name, view_name) -> dns.zone.Zone:
return zone return zone
def _generate_member_identifier() -> None: def _generate_member_identifier() -> None:
return b32encode(uuid4().bytes)[0:26].lower().decode('UTF-8') return b32encode(uuid4().bytes)[0:26].lower().decode("UTF-8")
def update_member_identifier(zone: Zone) -> None: def update_member_identifier(zone: Zone) -> None:
CatalogZoneMemberIdentifier.objects.update_or_create( CatalogZoneMemberIdentifier.objects.update_or_create(
zone=zone, zone=zone,
defaults={"name": _generate_member_identifier}, defaults={"name": _generate_member_identifier()},
) )
@@ -2,19 +2,15 @@ import logging
import socketserver import socketserver
import socket import socket
logger = logging.getLogger("dns-transfer-endpoint") logger = logging.getLogger(__name__)
class DNSAddressMixin: class DNSAddressMixin:
def _resolve_address(self, server_address, socktype, proto): def _resolve_address(self, server_address, socktype, proto):
host, port = server_address host, port = server_address
infos = socket.getaddrinfo( infos = socket.getaddrinfo(
host, host, port, socket.AF_UNSPEC, socktype, proto, socket.AI_PASSIVE
port,
socket.AF_UNSPEC,
socktype,
proto,
socket.AI_PASSIVE
) )
family, _, _, _, sockaddr = infos[0] family, _, _, _, sockaddr = infos[0]
@@ -27,9 +23,7 @@ class TCPDNSServer(DNSAddressMixin, socketserver.TCPServer):
def __init__(self, server_address, handler_class, keyring, tsig_view_map): def __init__(self, server_address, handler_class, keyring, tsig_view_map):
sockaddr = self._resolve_address( sockaddr = self._resolve_address(
server_address, server_address, socket.SOCK_STREAM, socket.IPPROTO_TCP
socket.SOCK_STREAM,
socket.IPPROTO_TCP
) )
super().__init__(sockaddr, handler_class) super().__init__(sockaddr, handler_class)
@@ -43,9 +37,7 @@ class UDPDNSServer(DNSAddressMixin, socketserver.UDPServer):
def __init__(self, server_address, handler_class, keyring, tsig_view_map): def __init__(self, server_address, handler_class, keyring, tsig_view_map):
sockaddr = self._resolve_address( sockaddr = self._resolve_address(
server_address, server_address, socket.SOCK_DGRAM, socket.IPPROTO_UDP
socket.SOCK_DGRAM,
socket.IPPROTO_UDP
) )
super().__init__(sockaddr, handler_class) super().__init__(sockaddr, handler_class)
@@ -4,14 +4,17 @@ import dns.rdatatype
import dns.rdataclass import dns.rdataclass
import dns.exception import dns.exception
import netbox_dns.models import netbox_dns.models
from netbox_plugin_bind_provisioner.utils import export_bind_zone_file from netbox_dns_bridge.utils import export_bind_zone_file
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
class Command(BaseCommand): class Command(BaseCommand):
def add_arguments(self, parser): def add_arguments(self, parser):
parser.add_argument( parser.add_argument(
"--view", type=str, help="The name of the view the Zone to be exported is in" "--view",
type=str,
help="The name of the view the Zone to be exported is in",
) )
parser.add_argument( parser.add_argument(
"--zone", type=str, help="The FQDN of the Zone to be exported" "--zone", type=str, help="The FQDN of the Zone to be exported"
@@ -20,16 +23,15 @@ class Command(BaseCommand):
"--file", type=str, help="Path of the zone file to be written" "--file", type=str, help="Path of the zone file to be written"
) )
def handle(self, *args, **options): def handle(self, *args, **options):
#if len(options) < 2: # if len(options) < 2:
# print("export-zone <zone name> <file path>") # print("export-zone <zone name> <file path>")
# sys.exit(1) # sys.exit(1)
# Load parameters # Load parameters
view_name = options['view'] view_name = options["view"]
zone_name = options['zone'] zone_name = options["zone"]
file_path = options['file'] file_path = options["file"]
if not view_name: if not view_name:
raise CommandError("No --view parameter given") raise CommandError("No --view parameter given")
@@ -40,7 +42,9 @@ class Command(BaseCommand):
try: try:
# Load the zone from NetBox DNS # Load the zone from NetBox DNS
nb_zone = netbox_dns.models.Zone.objects.get(view__name=view_name, name=zone_name) nb_zone = netbox_dns.models.Zone.objects.get(
view__name=view_name, name=zone_name
)
if nb_zone: if nb_zone:
export_bind_zone_file(nb_zone, file_path=file_path) export_bind_zone_file(nb_zone, file_path=file_path)
@@ -51,6 +55,6 @@ class Command(BaseCommand):
except Exception as e: except Exception as e:
raise CommandError(f"Failed to export zone: {e}") raise CommandError(f"Failed to export zone: {e}")
self.stdout.write(self.style.SUCCESS(f"Zone '{zone_name}' exported to '{file_path}'")) self.stdout.write(
self.style.SUCCESS(f"Zone '{zone_name}' exported to '{file_path}'")
)
@@ -4,19 +4,22 @@ import dns.rdatatype
import dns.rdataclass import dns.rdataclass
import dns.exception import dns.exception
import netbox_dns.models import netbox_dns.models
from netbox_plugin_bind_provisioner.utils import export_bind_zone_file from netbox_dns_bridge.utils import export_bind_zone_file
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
class Command(BaseCommand): class Command(BaseCommand):
def add_arguments(self, parser): def add_arguments(self, parser):
parser.add_argument( parser.add_argument(
"--path", type=str, help="Path to the directory where zone files are to be written" "--path",
type=str,
help="Path to the directory where zone files are to be written",
) )
def handle(self, *args, **options): def handle(self, *args, **options):
# Load parameters # Load parameters
base_path = options['path'] base_path = options["path"]
if not base_path: if not base_path:
raise CommandError("No --path parameter given") raise CommandError("No --path parameter given")
@@ -42,6 +45,8 @@ class Command(BaseCommand):
try: try:
# Call existing export function # Call existing export function
export_bind_zone_file(zone, file_path=file_path) export_bind_zone_file(zone, file_path=file_path)
self.stdout.write(self.style.SUCCESS(f"Exported zone '{zone.name}' to '{file_path}'")) self.stdout.write(
self.style.SUCCESS(f"Exported zone '{zone.name}' to '{file_path}'")
)
except Exception as e: except Exception as e:
self.stderr.write(f"Failed to export zone '{zone.name}': {e}") self.stderr.write(f"Failed to export zone '{zone.name}': {e}")
@@ -0,0 +1,51 @@
from django.core.management.base import BaseCommand, CommandError
from netbox_dns_bridge.models import IntegerKeyValueSetting
class Command(BaseCommand):
help = "Get or set integer key-value settings"
def add_arguments(self, parser):
parser.add_argument(
"action", choices=["get", "set", "list"], help="Action to perform"
)
parser.add_argument("key", nargs="?", help="Setting key")
parser.add_argument(
"value", nargs="?", type=int, help="Value to set (required for 'set')"
)
def handle(self, *args, **options):
action = options["action"]
key = options.get("key")
value = options.get("value")
if action == "list":
settings = IntegerKeyValueSetting.objects.all()
if not settings.exists():
self.stdout.write("No settings found.")
return
for setting in settings:
self.stdout.write(str(setting))
elif action == "get":
if not key:
raise CommandError("A key is required for GET")
try:
setting = IntegerKeyValueSetting.objects.get(key=key)
self.stdout.write(f"{setting.key}: {setting.value}")
except IntegerKeyValueSetting.DoesNotExist:
raise CommandError(f"No setting was found for {key}")
elif action == "set":
if not key:
raise CommandError("A setting is required for SET command")
if value is None:
raise CommandError("A value is required for SET command")
try:
setting = IntegerKeyValueSetting.objects.get(key=key)
old_value = setting.value
setting.value = value
setting.save()
self.stdout.write(f"Updated {key} from {old_value} to {value}")
except IntegerKeyValueSetting.DoesNotExist:
raise CommandError(f"No setting found for {key}")
@@ -14,19 +14,19 @@ import dns.renderer
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from django.conf import settings from django.conf import settings
from netbox_dns.models import View from netbox_dns.models import View
from netbox_plugin_bind_provisioner.service.endpoint.request_handler import UDPRequestHandler, TCPRequestHandler from netbox_dns_bridge.request_handler import UDPRequestHandler, TCPRequestHandler
from netbox_plugin_bind_provisioner.service.endpoint.dns_server import UDPDNSServer, TCPDNSServer from netbox_dns_bridge.dns_server import UDPDNSServer, TCPDNSServer
from netbox_plugin_bind_provisioner.service.endpoint import catalog_zone_manager as catzm from netbox_dns_bridge import catalog_zone_manager as catzm
from netbox_dns_bridge.models import IntegerKeyValueSetting
logger = logging.getLogger(__name__)
logger = logging.getLogger("dns-transfer-endpoint")
class Command(BaseCommand): class Command(BaseCommand):
help = "Run a minimal AXFR DNS server using data from NetBox DNS plugin" help = "Run a minimal AXFR DNS server using data from NetBox DNS plugin"
def load_settings(self): def load_settings(self):
self.settings = settings.PLUGINS_CONFIG.get( self.settings = settings.PLUGINS_CONFIG.get("netbox_dns_bridge", None)
"netbox_plugin_bind_provisioner", None
)
if not self.settings: if not self.settings:
raise RuntimeError( raise RuntimeError(
"Command failed to initialize due to missing settings. Terminating Netbox." "Command failed to initialize due to missing settings. Terminating Netbox."
@@ -0,0 +1,58 @@
# Generated by Django 5.2.9 on 2026-04-08 11:29
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
(
"netbox_dns",
"0030_dnsseckeytemplate_comments_dnsseckeytemplate_owner_and_more",
),
]
operations = [
migrations.CreateModel(
name="IntegerKeyValueSetting",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False
),
),
("key", models.CharField(max_length=64)),
("value", models.IntegerField()),
],
options={
"default_permissions": (),
},
),
migrations.CreateModel(
name="CatalogZoneMemberIdentifier",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False
),
),
("name", models.CharField(max_length=26, unique=True)),
(
"zone",
models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE,
related_name="catz_identifier",
to="netbox_dns.zone",
),
),
],
options={
"ordering": ("name",),
},
),
]
Whitespace-only changes.
@@ -2,6 +2,7 @@ from django.db import models
import netbox.models import netbox.models
import netbox_dns.models import netbox_dns.models
class IntegerKeyValueSetting(models.Model): class IntegerKeyValueSetting(models.Model):
key = models.CharField(max_length=64) key = models.CharField(max_length=64)
value = models.IntegerField() value = models.IntegerField()
@@ -12,6 +13,7 @@ class IntegerKeyValueSetting(models.Model):
class Meta: class Meta:
default_permissions = () default_permissions = ()
class CatalogZoneMemberIdentifier(models.Model): class CatalogZoneMemberIdentifier(models.Model):
name = models.CharField( name = models.CharField(
max_length=26, max_length=26,
@@ -13,9 +13,9 @@ import dns.exception
import dns.renderer import dns.renderer
from netbox_dns.models import Zone, Record from netbox_dns.models import Zone, Record
from netbox_dns.choices import ZoneStatusChoices, RecordStatusChoices from netbox_dns.choices import ZoneStatusChoices, RecordStatusChoices
from . import catalog_zone_manager as catzm from netbox_dns_bridge import catalog_zone_manager as catzm
logger = logging.getLogger("dns-transfer-endpoint") logger = logging.getLogger(__name__)
class DNSBaseRequestHandler(socketserver.BaseRequestHandler): class DNSBaseRequestHandler(socketserver.BaseRequestHandler):
@@ -114,7 +114,7 @@ class DNSBaseRequestHandler(socketserver.BaseRequestHandler):
zone.replace_rdataset(name, rdataset) zone.replace_rdataset(name, rdataset)
return zone return zone
def _denyRequestBadTSIG(self, wire, tsig_error: dns.rcode) -> None: def _deny_request_bad_tsig(self, wire, tsig_error: dns.rcode) -> None:
# Use empty keyring to parse TSIG without validating # Use empty keyring to parse TSIG without validating
query = dns.message.from_wire( query = dns.message.from_wire(
wire, keyring={}, ignore_trailing=True, continue_on_error=True wire, keyring={}, ignore_trailing=True, continue_on_error=True
@@ -125,13 +125,13 @@ class DNSBaseRequestHandler(socketserver.BaseRequestHandler):
response.set_rcode(dns.rcode.REFUSED) response.set_rcode(dns.rcode.REFUSED)
if query.had_tsig: if query.had_tsig:
# Add TSIG with BADKEY, but do not sign (no MAC) # Add TSIG with error code, but do not sign (no MAC, empty keyring)
response.use_tsig( response.use_tsig(
keyring={}, # empty; we're not signing keyring={}, # empty; we're not signing
keyname=query.keyname, keyname=query.keyname,
tsig_error=tsig_error, tsig_error=tsig_error,
) )
self.denyRequest(query) self._send_response(response.to_wire())
def _send_response(self, data) -> None: def _send_response(self, data) -> None:
raise NotImplementedError raise NotImplementedError
@@ -164,23 +164,27 @@ class DNSBaseRequestHandler(socketserver.BaseRequestHandler):
self.server.keyring, keyname=query.keyname, original_id=query.id self.server.keyring, keyname=query.keyname, original_id=query.id
) )
else: else:
# If key is unknown # unknown key — use an empty keyring so use_tsig() does not
# raise KeyError trying to look up a key that isn't present.
response.set_rcode(dns.rcode.REFUSED) response.set_rcode(dns.rcode.REFUSED)
# Generate new key for keyname provided
# keyname = query.keyname
# b64 = base64.b64encode(urandom(32)).decode("ascii")
# newkey = dns.tsigkeyring.from_text({ keyname: b64 })
response.use_tsig( response.use_tsig(
self.server.keyring, {}, # empty keyring; no signing
keyname=query.keyname, keyname=query.keyname,
tsig_error=dns.rcode.BADKEY, tsig_error=dns.rcode.BADKEY,
) )
data = response.to_wire(max_size=512) data = response.to_wire(max_size=512)
self._send_response(data) self._send_response(data)
logger.debug(f"{peer} SOA {nb_view.name}/{dname}") logger.info(f"{peer} SOA {nb_view.name}/{dname}")
def _handle_axfr_request(self, query, zone, peer, nb_view, dname) -> None: def _handle_axfr_request(self, query, zone, peer, nb_view, dname) -> None:
if query.keyname not in self.server.keyring:
logger.error(f"AXFR aborted: keyname {query.keyname} not in keyring")
self._deny_request(query)
return
tsig_key = self.server.keyring[query.keyname]
rrsets = [] rrsets = []
soa_rrset = None soa_rrset = None
for name, rdataset in zone.iterate_rdatasets(): for name, rdataset in zone.iterate_rdatasets():
@@ -211,9 +215,7 @@ class DNSBaseRequestHandler(socketserver.BaseRequestHandler):
# 3. Loop through RRsets # 3. Loop through RRsets
tsig_ctx = None tsig_ctx = None
for rrset in rrsets: for rrset in rrsets:
# logger.debug(f"Iterating over rrset {rrset}. tsig_ctx: {tsig_ctx}")
try: try:
# logger.debug(f"Adding {rrset} to renderer object")
r.add_rrset(dns.renderer.ANSWER, rrset) r.add_rrset(dns.renderer.ANSWER, rrset)
if r.max_size - len(r.output.getvalue()) < self.RESERVED_TSIG: if r.max_size - len(r.output.getvalue()) < self.RESERVED_TSIG:
raise dns.exception.TooBig("TSIG wont fit") raise dns.exception.TooBig("TSIG wont fit")
@@ -222,7 +224,8 @@ class DNSBaseRequestHandler(socketserver.BaseRequestHandler):
r.write_header() r.write_header()
tsig_ctx = r.add_multi_tsig( tsig_ctx = r.add_multi_tsig(
ctx=tsig_ctx, ctx=tsig_ctx,
secret=self.server.keyring[query.keyname], secret=tsig_key.secret,
algorithm=tsig_key.algorithm,
keyname=query.keyname, keyname=query.keyname,
fudge=300, fudge=300,
id=query.id, id=query.id,
@@ -245,26 +248,33 @@ class DNSBaseRequestHandler(socketserver.BaseRequestHandler):
query.question[0].rdtype, query.question[0].rdtype,
query.question[0].rdclass, query.question[0].rdclass,
) )
try:
r.add_rrset(dns.renderer.ANSWER, rrset) r.add_rrset(dns.renderer.ANSWER, rrset)
except dns.exception.TooBig:
logger.error(
f"RRset {rrset.name}/{dns.rdatatype.to_text(rrset.rdtype)} "
f"exceeds MAX_WIRE ({self.MAX_WIRE}) and cannot be sent; "
f"skipping."
)
# 4. Final message with terminating TSIG # 4. Final message with terminating TSIG
r.write_header() r.write_header()
# logger.debug(f"Final message. tsig_ctx: {tsig_ctx}")
tsig_ctx = r.add_multi_tsig( tsig_ctx = r.add_multi_tsig(
ctx=tsig_ctx, ctx=tsig_ctx,
secret=self.server.keyring[query.keyname], secret=tsig_key.secret,
algorithm=tsig_key.algorithm,
keyname=query.keyname, keyname=query.keyname,
fudge=300, fudge=300,
id=query.id, id=query.id,
tsig_error=0, tsig_error=0,
other_data=b"", other_data=b"",
# request_mac=r.mac if tsig_ctx else None,
request_mac=r.mac if tsig_ctx else query.mac, request_mac=r.mac if tsig_ctx else query.mac,
) )
wire = r.get_wire() wire = r.get_wire()
self._send_response(wire) self._send_response(wire)
logger.debug(f"{peer} AXFR {nb_view.name}/{dname}") logger.info(f"{peer} AXFR {nb_view.name}/{dname}")
def _handle_dns_query(self, wire) -> None: def _handle_dns_query(self, wire) -> None:
peer = self.client_address[0] peer = self.client_address[0]
@@ -273,19 +283,17 @@ class DNSBaseRequestHandler(socketserver.BaseRequestHandler):
wire, wire,
keyring=self.server.keyring, keyring=self.server.keyring,
continue_on_error=False, continue_on_error=False,
ignore_trailing=True ignore_trailing=True,
) )
except dns.tsig.BadSignature as e: except dns.tsig.BadSignature as e:
logger.warning( logger.warning(f"Request denied from {peer} failed TSIG verification: {e}")
f"Request denied from {peer} failed TSIG verification: {e}" self._deny_request_bad_tsig(wire, dns.rcode.BADSIG)
)
self._denyRequestBadTSIG(wire, dns.rcode.BADSIG)
return return
except (dns.message.UnknownTSIGKey, dns.tsig.BadAlgorithm) as e: except (dns.message.UnknownTSIGKey, dns.tsig.BadAlgorithm) as e:
logger.warning(f"Request denied from {peer} with bad TSIG key: {e}") logger.warning(f"Request denied from {peer} with bad TSIG key: {e}")
self._denyRequestBadTSIG(wire, dns.rcode.BADKEY) self._deny_request_bad_tsig(wire, dns.rcode.BADKEY)
return return
except Exception as e: except Exception as e:
@@ -366,6 +374,7 @@ class UDPRequestHandler(DNSBaseRequestHandler):
except Exception as e: except Exception as e:
logger.error(f"Error handling request from {peer}: {e}") logger.error(f"Error handling request from {peer}: {e}")
import traceback import traceback
traceback.print_exc() traceback.print_exc()
@@ -409,5 +418,5 @@ class TCPRequestHandler(DNSBaseRequestHandler):
except Exception as e: except Exception as e:
logger.error(f"Error handling request from {peer}: {e}") logger.error(f"Error handling request from {peer}: {e}")
import traceback import traceback
traceback.print_exc()
traceback.print_exc()
@@ -1,7 +1,8 @@
from django.db.models.signals import pre_save, post_save from django.db.models.signals import pre_save, post_save
from django.dispatch import receiver from django.dispatch import receiver
from netbox_dns.models import Zone from netbox_dns.models import Zone
from .service.endpoint import catalog_zone_manager as catzm from . import catalog_zone_manager as catzm
@receiver(pre_save, sender=Zone) @receiver(pre_save, sender=Zone)
def zone_pre_save(sender, instance, **kwargs): def zone_pre_save(sender, instance, **kwargs):
@@ -10,17 +11,13 @@ def zone_pre_save(sender, instance, **kwargs):
""" """
if instance.pk: if instance.pk:
try: try:
instance._old_name = ( instance._old_name = sender.objects.only("name").get(pk=instance.pk).name
sender.objects
.only("name")
.get(pk=instance.pk)
.name
)
except sender.DoesNotExist: except sender.DoesNotExist:
instance._old_name = None instance._old_name = None
else: else:
instance._old_name = None instance._old_name = None
@receiver(post_save, sender=Zone) @receiver(post_save, sender=Zone)
def sync_catalog_zone_identifier(sender, instance, created, **kwargs): def sync_catalog_zone_identifier(sender, instance, created, **kwargs):
""" """
@@ -5,6 +5,7 @@ import dns.rdataclass
import dns.exception import dns.exception
import netbox_dns.models import netbox_dns.models
def export_bind_zone_file(nb_zone: netbox_dns.models.Zone, file_path: str): def export_bind_zone_file(nb_zone: netbox_dns.models.Zone, file_path: str):
# Create dnspython zone object # Create dnspython zone object
@@ -19,8 +20,8 @@ def export_bind_zone_file(nb_zone: netbox_dns.models.Zone, file_path: str):
rdata = dns.rdata.from_text(rdclass, rdatatype, record.value) rdata = dns.rdata.from_text(rdclass, rdatatype, record.value)
# Create rdataset # Create rdataset
rdataset = dns.rdataset.Rdataset(rdclass, rdatatype, record.ttl) rdataset = dns.rdataset.Rdataset(rdclass, rdatatype)
rdataset.add(rdata) rdataset.add(rdata, record.ttl)
# Add to zone # Add to zone
node = dp_zone.find_node(rname, create=True) node = dp_zone.find_node(rname, create=True)
@@ -32,4 +33,3 @@ def export_bind_zone_file(nb_zone: netbox_dns.models.Zone, file_path: str):
dp_zone.to_file(f, sorted=True) dp_zone.to_file(f, sorted=True)
except IOError as e: except IOError as e:
raise IOError(f"Failed to write zone file to {file_path}: {e}") raise IOError(f"Failed to write zone file to {file_path}: {e}")
+10 -7
View File
@@ -3,27 +3,30 @@ requires = ["setuptools>=61", "wheel"]
build-backend = "setuptools.build_meta" build-backend = "setuptools.build_meta"
[project] [project]
name = "netbox-plugin-bind-provisioner" name = "netbox-plugin-dns-bridge"
dynamic = ["version"] dynamic = ["version"]
description = "A Bind provisioning plugin that uses netbox_dns for its data source" description = "A bridge between netbox-plugin-dns and your DNS infrastructure."
authors = [ authors = [
{ name = "Sven Luethi" }, { name = "Sven Luethi" },
] ]
license = { text = "GPL-2.0" } license = { file = "LICENSE.md" }
readme = "README.md" readme = "README.md"
requires-python = ">=3.7" requires-python = ">=3.7"
dependencies = ["netbox-plugin-dns"] dependencies = [
"netbox-plugin-dns>=1.5.0",
"dnspython>=2.8.0"
]
[tool.setuptools] [tool.setuptools]
include-package-data = true include-package-data = true
zip-safe = false zip-safe = false
package-dir = { "" = "src" } package-dir = { "" = "." }
[tool.setuptools.packages.find] [tool.setuptools.packages.find]
where = ["src"] where = ["."]
[tool.setuptools.dynamic] [tool.setuptools.dynamic]
version = { attr = "netbox_plugin_bind_provisioner.__version__" } version = { attr = "netbox_dns_bridge.__version__" }
[project.urls] [project.urls]
Homepage = "https://github.com/Suraxius/netbox-plugin-bind-provisioner" Homepage = "https://github.com/Suraxius/netbox-plugin-bind-provisioner"
-2
View File
@@ -1,2 +0,0 @@
netbox-plugin-dns>=1.2.0
dnspython>=2.8.0
@@ -1,51 +0,0 @@
# Generated by Django 5.2.8 on 2025-11-23 14:36
import netbox.models.deletion
import taggit.managers
import utilities.json
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
("extras", "0133_make_cf_minmax_decimal"),
]
operations = [
migrations.CreateModel(
name="IntegerKeyValueSetting",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False
),
),
("created", models.DateTimeField(auto_now_add=True, null=True)),
("last_updated", models.DateTimeField(auto_now=True, null=True)),
(
"custom_field_data",
models.JSONField(
blank=True,
default=dict,
encoder=utilities.json.CustomFieldJSONEncoder,
),
),
("key", models.CharField(max_length=64)),
("value", models.IntegerField()),
(
"tags",
taggit.managers.TaggableManager(
through="extras.TaggedItem", to="extras.Tag"
),
),
],
options={
"abstract": False,
},
bases=(netbox.models.deletion.DeleteMixin, models.Model),
),
]
@@ -1,33 +0,0 @@
# Generated by Django 5.2.6 on 2025-12-18 14:51
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('netbox_plugin_bind_provisioner', '0001_initial'),
]
operations = [
migrations.AlterModelOptions(
name='integerkeyvaluesetting',
options={'default_permissions': ()},
),
migrations.RemoveField(
model_name='integerkeyvaluesetting',
name='created',
),
migrations.RemoveField(
model_name='integerkeyvaluesetting',
name='custom_field_data',
),
migrations.RemoveField(
model_name='integerkeyvaluesetting',
name='last_updated',
),
migrations.RemoveField(
model_name='integerkeyvaluesetting',
name='tags',
),
]
@@ -1,26 +0,0 @@
# Generated by Django 5.2.9 on 2026-02-02 09:23
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('netbox_dns', '0030_dnsseckeytemplate_comments_dnsseckeytemplate_owner_and_more'),
('netbox_plugin_bind_provisioner', '0002_alter_integerkeyvaluesetting_options_and_more'),
]
operations = [
migrations.CreateModel(
name='CatalogZoneMemberIdentifier',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
('name', models.CharField(max_length=26, unique=True)),
('zone', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bind_provisioner_models', to='netbox_dns.zone')),
],
options={
'ordering': ('name',),
},
),
]
@@ -1,20 +0,0 @@
# Generated by Django 5.2.9 on 2026-02-02 10:53
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('netbox_dns', '0030_dnsseckeytemplate_comments_dnsseckeytemplate_owner_and_more'),
('netbox_plugin_bind_provisioner', '0003_catalogzonememberidentifier'),
]
operations = [
migrations.AlterField(
model_name='catalogzonememberidentifier',
name='zone',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bind_provisioner_catz_identifier', to='netbox_dns.zone'),
),
]
@@ -1,20 +0,0 @@
# Generated by Django 5.2.9 on 2026-02-02 20:49
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('netbox_dns', '0030_dnsseckeytemplate_comments_dnsseckeytemplate_owner_and_more'),
('netbox_plugin_bind_provisioner', '0004_alter_catalogzonememberidentifier_zone'),
]
operations = [
migrations.AlterField(
model_name='catalogzonememberidentifier',
name='zone',
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='catz_identifier', to='netbox_dns.zone'),
),
]