Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #166 : DNS Support #398

Closed
wants to merge 45 commits into from
Closed

Conversation

rdujardin
Copy link

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.

rdujardin added 30 commits July 20, 2016 15:24
Add description to zone, add category and description to record
output the whole zone if prefix is smaller than the zone
Make them auto-update only on export if changes and not on every modification in the (reverse) zone
rdujardin added 2 commits July 28, 2016 16:34
Last of initial commits for DNS support
@ventris
Copy link

ventris commented Aug 1, 2016

Nice work

@jeremystretch
Copy link
Member

Hey, so, this is clearly a lot of work and I appreciate that. But I wish you had synced with me before you started. I had no idea you were working on this; DNS support hasn't even been added to the roadmap yet. I'm afraid I don't have time at the moment to review the data model and address all the conflicts presented here.

I'm going to put this on hold until we figure out a spot for it, which won't be until after custom fields have been implemented, at the earliest. I'd love to get this implemented in NetBox, but the roadmap takes priority.

rdujardin added 3 commits August 3, 2016 11:00
Note : Adding DNS conflicted with adding Tenant fields and modifying VRF fields in IPAM.
@rdujardin
Copy link
Author

Hello.

I understand, I have posted some messages on the issue but I didn't told you directly, it's my bad.

I have merged with current develop branch and solved the conflicts, it will be less work for you to check this if you want to get it integrated into Netbox.

Thank you for the answer.

@rdujardin
Copy link
Author

Hello.

I added a few commits to :

  • allow A/AAAA autocreating when PTR is given a FQDN, which means that if you have a zone "foo.net", both PTR "something.foo.net" and "something.foo.net." will be taken into account
  • fix a bug with A/AAAA autocreating when adding a new IP address (there was a bug because the record was saved before the address, which caused a problem as the record has a foreign key on the ip address)

And I merged with current develop branch. :)

@rdujardin
Copy link
Author

I added a char field 'extra_conf' (max length 500) to store extra config data about a zone (or a reverse zone). For instance, in NSD, zones can have a parameter 'notify' which indicates the IP of the slave DNS server to notify. These parameters can be textually added in this field since it supports '\n'.

@visbits
Copy link

visbits commented Aug 25, 2016

Once this is merged, netbox is rapidly becoming the best dcim tool ive seen.

@csfreak
Copy link

csfreak commented Aug 29, 2016

Now that custom fields, has been merged to develop, can we get this on the roadmap?

@rdujardin
Copy link
Author

I added some fixes that I don't have pushed here yet, and I need to do a bit of code cleaning again. Please don't merge now, in a few days it will be ready. :)

@marc-us
Copy link
Contributor

marc-us commented Oct 9, 2016

Please merge this into master. It is a necessary feature.

@angystardust
Copy link

@rdujardin does it support TXT records?

@viennaa
Copy link

viennaa commented Dec 8, 2016

@rdujardin Is it likely that you commit your changes from August?

@jsenecal jsenecal mentioned this pull request Dec 15, 2016
@sts
Copy link

sts commented Jan 14, 2017

@rdujardin Can you provide some screenshots of the current version?

@jeremystretch
Copy link
Member

I'm going to close out this PR as it has stagnated. I'd still like to add DNS support to NetBox in the future, but there are several more pressing features (such as a writeable API) that I want to implement first.

@kztime
Copy link

kztime commented Feb 19, 2019

@rdujardin Hi! What did you decide in the end? I also need this feature and me too working on it.

@DanSheps
Copy link
Member

@kztime

I'm going to close out this PR as it has stagnated. I'd still like to add DNS support to NetBox in the future, but there are several more pressing features (such as a writeable API) that I want to implement first.

It is still roadmapped for the future, as per the above, but right now I believe there are still more pressing issues.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.