[PR #398] [CLOSED] Fix #166 : DNS Support #12053

Closed
opened 2025-12-29 22:19:21 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/398
Author: @rdujardin
Created: 7/28/2016
Status: Closed

Base: developHead: develop


📝 Commits (10+)

  • 5ea721a Fixes #166: Full DNS support
  • 2d39984 Add help texts in DNS forms
  • 4046d69 In DNS : change search/filters & add bind exports
  • 6230ae1 Add bind exports in dns api
  • efe6188 Add fields to dns models
  • 117bf1a Remove category field in record & add auto-updating serial in zone
  • 02e142e Fix zone serial updating on records bulk delete
  • 90ea564 Add reverse DNS
  • 0a39945 Fix bug in ipv6 reverse dns
  • d6fd35d Fix bug in ipv6 reverse dns (bis)

📊 Changes

60 files changed (+2472 additions, -28 deletions)

View changed files

docs/data-model/dns.md (+41 -0)
📝 docs/index.md (+1 -0)
netbox/dns/__init__.py (+1 -0)
netbox/dns/admin.py (+18 -0)
netbox/dns/api/__init__.py (+0 -0)
netbox/dns/api/serializers.py (+42 -0)
netbox/dns/api/urls.py (+19 -0)
netbox/dns/api/views.py (+76 -0)
netbox/dns/apps.py (+6 -0)
netbox/dns/filters.py (+53 -0)
netbox/dns/fixtures/dns.json (+37 -0)
netbox/dns/formfields.py (+39 -0)
netbox/dns/forms.py (+156 -0)
netbox/dns/migrations/0001_initial.py (+59 -0)
netbox/dns/migrations/0002_auto_20160719_1058.py (+20 -0)
netbox/dns/migrations/0003_auto_20160721_1059.py (+34 -0)
netbox/dns/migrations/0004_auto_20160722_0820.py (+29 -0)
netbox/dns/migrations/0005_auto_20160728_0854.py (+25 -0)
netbox/dns/migrations/0006_zone_extra_conf.py (+20 -0)
netbox/dns/migrations/__init__.py (+0 -0)

...and 40 more files

📄 Description

Hello,

I created a new DNS application, with its own menu and its two new objects Zone and Record. It handles DNS and Reverse DNS. It's essentially things added, but there are some modifications in IPAM too, in order to handle reverse DNS : I added an optional PTR field to IPAddress, and several optional fields to Prefix : ttl, soa_name, soa_contact, soa_serial, soa_refresh, soa_retry, soa_expire and soa_minimum, and I added a function to_bind() for reverse DNS exporting, and some triggers to update serials automatically.

It seems my fork isn't passing the build test, but when I forked the develop branch wasn't either, and I checked that errors didn't come from my code. So if you merge, no problem is expected as develop branch is now passing.

I have described my work in the issue #166 , and here is the doc page I wrote for the application :

Zones

A zone corresponds to a zone file in a DNS server, it stores the SOA (Start Of Authority) record and other records that are stored as Record objects.

Zone objects handle only forward DNS, reverse DNS is handled by Prefixes (in IPAM section), which also store a SOA record.

Netbox provides two views in the DNS menu to get the exports in BIND format, which is compatible with every DNS server, directly or by import. Those
exports are also accessible as JSON through the REST API. One of these views is the export of all the forward zones in the database,
the second is the export of all the reverse zones.

The reverse zones are correctly merged and/or divided to meet the requirements of a DNS server (for instance, IPv4 reverse zones must be /16 or /24), and
not to duplicate records (for instance if you have in database the prefixes 192.168.0.0/16 and 192.168.1.0/24, only the biggest will be exported) ; however,
only IP addresses which are in an active prefix will be taken into account. Obviously, reverse DNS is supported for both IPv4 and IPv6.

The SOA Serial field is not editable : it's automatically created and managed by Netbox. Each time a zone (forward or reverse) is exported,
if there are changes since the last export or if it's the first export, the serial will be incremented. It's in the following format :
YYYYMMDDNN with Y the year, M the month, D the day and N a two-digit counter.

As zones and their BIND exports are readable through the REST API, it is possible to write some external script to automatically update
your DNS server configuration from Netbox's database.


Record

Each Record object represents a DNS record, i.e. a link between a hostname and a resource, which can be either an IP address or a text value,
for instance another name if the record is of CNAME type.

Records must be linked to an existing zone, and hold either an IP address link or a text value. The "Address" field points to an IP address
in database, but if you want to put an IP in your record but not in your database (if you don't own the IP for instance), it's possible
by putting the IP as text value instead.

You can create, edit or import records with IPs not existing yet in the database. They will be automatically created (but not the prefixes !).
However, the zones must be created first, they won't be so automatically.

Reverse DNS is not supported by Record objects, but by the "PTR" field in IP addresses. If this field is modified and not empty, a corresponding
A/AAAA record is automatically created if the corresponding zone is found in the database. Be careful, if there was A/AAAA records
for the old PTR value, they are not deleted.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/398 **Author:** [@rdujardin](https://github.com/rdujardin) **Created:** 7/28/2016 **Status:** ❌ Closed **Base:** `develop` ← **Head:** `develop` --- ### 📝 Commits (10+) - [`5ea721a`](https://github.com/netbox-community/netbox/commit/5ea721a6aa37e14a4bf6e36b9ba619ec4ede7d64) Fixes #166: Full DNS support - [`2d39984`](https://github.com/netbox-community/netbox/commit/2d3998497e1189aa28b98292f279308c99648324) Add help texts in DNS forms - [`4046d69`](https://github.com/netbox-community/netbox/commit/4046d697fc257a27cc7311acf8edc4deb350c330) In DNS : change search/filters & add bind exports - [`6230ae1`](https://github.com/netbox-community/netbox/commit/6230ae13cc9fc63e448953b482326a66975caa35) Add bind exports in dns api - [`efe6188`](https://github.com/netbox-community/netbox/commit/efe61886a078c42740a0d82a44c74b34cd97baa0) Add fields to dns models - [`117bf1a`](https://github.com/netbox-community/netbox/commit/117bf1a118defead7f6843b4fa777d02c5c37e74) Remove category field in record & add auto-updating serial in zone - [`02e142e`](https://github.com/netbox-community/netbox/commit/02e142e1dea671abb5987fa37379977f61f8fcdc) Fix zone serial updating on records bulk delete - [`90ea564`](https://github.com/netbox-community/netbox/commit/90ea56489d132592c09c2f844b828d5af3bd4d59) Add reverse DNS - [`0a39945`](https://github.com/netbox-community/netbox/commit/0a39945afb11a7ee9bcd5cdb37a056884081421c) Fix bug in ipv6 reverse dns - [`d6fd35d`](https://github.com/netbox-community/netbox/commit/d6fd35dfd56c983f0c37538664a7290b9f714b8a) Fix bug in ipv6 reverse dns (bis) ### 📊 Changes **60 files changed** (+2472 additions, -28 deletions) <details> <summary>View changed files</summary> ➕ `docs/data-model/dns.md` (+41 -0) 📝 `docs/index.md` (+1 -0) ➕ `netbox/dns/__init__.py` (+1 -0) ➕ `netbox/dns/admin.py` (+18 -0) ➕ `netbox/dns/api/__init__.py` (+0 -0) ➕ `netbox/dns/api/serializers.py` (+42 -0) ➕ `netbox/dns/api/urls.py` (+19 -0) ➕ `netbox/dns/api/views.py` (+76 -0) ➕ `netbox/dns/apps.py` (+6 -0) ➕ `netbox/dns/filters.py` (+53 -0) ➕ `netbox/dns/fixtures/dns.json` (+37 -0) ➕ `netbox/dns/formfields.py` (+39 -0) ➕ `netbox/dns/forms.py` (+156 -0) ➕ `netbox/dns/migrations/0001_initial.py` (+59 -0) ➕ `netbox/dns/migrations/0002_auto_20160719_1058.py` (+20 -0) ➕ `netbox/dns/migrations/0003_auto_20160721_1059.py` (+34 -0) ➕ `netbox/dns/migrations/0004_auto_20160722_0820.py` (+29 -0) ➕ `netbox/dns/migrations/0005_auto_20160728_0854.py` (+25 -0) ➕ `netbox/dns/migrations/0006_zone_extra_conf.py` (+20 -0) ➕ `netbox/dns/migrations/__init__.py` (+0 -0) _...and 40 more files_ </details> ### 📄 Description Hello, I created a new DNS application, with its own menu and its two new objects Zone and Record. It handles DNS and Reverse DNS. It's essentially things added, but there are some modifications in IPAM too, in order to handle reverse DNS : I added an optional PTR field to IPAddress, and several optional fields to Prefix : ttl, soa_name, soa_contact, soa_serial, soa_refresh, soa_retry, soa_expire and soa_minimum, and I added a function to_bind() for reverse DNS exporting, and some triggers to update serials automatically. It seems my fork isn't passing the build test, but when I forked the develop branch wasn't either, and I checked that errors didn't come from my code. So if you merge, no problem is expected as develop branch is now passing. I have described my work in the issue #166 , and here is the doc page I wrote for the application : # Zones A zone corresponds to a zone file in a DNS server, it stores the SOA (Start Of Authority) record and other records that are stored as Record objects. Zone objects handle only forward DNS, reverse DNS is handled by Prefixes (in IPAM section), which also store a SOA record. Netbox provides two views in the DNS menu to get the exports in BIND format, which is compatible with every DNS server, directly or by import. Those exports are also accessible as JSON through the REST API. One of these views is the export of all the forward zones in the database, the second is the export of all the reverse zones. The reverse zones are correctly merged and/or divided to meet the requirements of a DNS server (for instance, IPv4 reverse zones must be /16 or /24), and not to duplicate records (for instance if you have in database the prefixes 192.168.0.0/16 and 192.168.1.0/24, only the biggest will be exported) ; however, only IP addresses which are in an active prefix will be taken into account. Obviously, reverse DNS is supported for both IPv4 and IPv6. The SOA Serial field is not editable : it's automatically created and managed by Netbox. Each time a zone (forward or reverse) is exported, if there are changes since the last export or if it's the first export, the serial will be incremented. It's in the following format : YYYYMMDDNN with Y the year, M the month, D the day and N a two-digit counter. As zones and their BIND exports are readable through the REST API, it is possible to write some external script to automatically update your DNS server configuration from Netbox's database. --- # Record Each Record object represents a DNS record, i.e. a link between a hostname and a resource, which can be either an IP address or a text value, for instance another name if the record is of CNAME type. Records must be linked to an existing zone, and hold either an IP address link or a text value. The "Address" field points to an IP address in database, but if you want to put an IP in your record but not in your database (if you don't own the IP for instance), it's possible by putting the IP as text value instead. You can create, edit or import records with IPs not existing yet in the database. They will be automatically created (but not the prefixes !). However, the zones must be created first, they won't be so automatically. Reverse DNS is not supported by Record objects, but by the "PTR" field in IP addresses. If this field is modified and not empty, a corresponding A/AAAA record is automatically created if the corresponding zone is found in the database. Be careful, if there was A/AAAA records for the old PTR value, they are not deleted. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 22:19:21 +01:00
adam closed this issue 2025-12-29 22:19:22 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#12053