auroraresearchlab/netbox-dns

How this plugin works

Closed this issue · 7 comments

Hello,

I just installed the plugin in my Netbox instance.
I can create DNS servers and zones, it works great. I'm just wondering how the existing devices and addresses are now migrated to this zone.

Is this plugin just for manually managing DNS zones or should the information from new or existing devices be automatically created as a DNS entry? I can't see a field on either devices or addresses to map to a DNS zone.

Greetings
Daniel

Hi Daniel,

thanks for the feedback! I'm glad you find the plugin useful.

As for integration with the rest of NetBox ... currently there is no automatism in place that would transfer data from NetBox to DNS zones. The reason is that linking existing data to DNS is by no means trivial and obvious - there are many possible scenarios that need to be addressed. So at the moment (there are some ideas being floated, but nothing tangible yet) there is no integrated mechanism to link IPAM data to NetBox DNS.

There is, however, a powerful scripting mechanism built into NetBox DNS that can be used to manually transfer existing IPAM data to NetBox DNS. Using a custom script it's possible to traverse e.g. existing NetBox 'IP Address' objects, take the 'DNS Name' and 'IP Address' field from them, and add them as A/AAAA records to NetBox DNS. Optionally, you could also create the forward and reverse zones while doing this - YMMV.

What's much more difficult is to create a mechanism to automatically synchronise IPAM and DNS data ... while things like duplicate addresses in different VRFs can be solved using views, there is the question of what should happen when IPAM data get updated or deleted, or when a device or virtual machine is removed (NetBox itself keeps the IPAM data, so probably the DNS records should be retained as well - but what should happen when an IP Address object or a Prefix object is deleted?

tl;dr
Tighter integration with IPAM is a planned feature, but not there yet (and will definitely take some time to be released), but custom scripts can be used to synchronise IPAM and DNS data and vice versa. When I find the time I can add some example scripts to the distribution so you have a base for your own solution - would that help you?

Hello and thank you for your answer. It's a pity that synchronization isn't possible at the moment. Since I've only been dealing with Netbox for a short time, I'm not familiar with the scripts yet. Therefore, a few examples (like in the general readme for everyone) would be very helpful.

I'll provide something as soon as I find the time. Stay tuned :-)

There's also more documentation in docs and some example code (also an example script for exporting NetBox DNS data to BIND) in examples, maybe there's some interesting stuff for you too.

Hi Daniel, I have something for you to play with.

DNS Name Record Updater

Creates or update DNS address records in zones with a specified View (default is None) for all IPAM 'IP Address' objects with a specified VRF (default is None).

Records will only be created for existing zones, new zones are never created. If there is no direct parent zone in NetBox DNS, no multi-label host names will be created either. If there are multiple address records within the specified view pointing to an address, no record will be created or updated. However the script will happily create duplicate names with different addresses to facilitate round robin DNS schemes.

There is a switch that allows overwriting existing records, the default setting is not to overwrite any conflicting values.

IPAM Hostname Updater

Creates or updates the 'DNS Name' field for all IPAM 'IP Address' objects with a specified VRF (default is None) from DNS address records in NetBox DNS.

If there are multiple address records pointing to an address the 'DNS Name' field will not be updated.

There is a switch that allows overwriting existing DNS names, the default setting is not to overwrite any conflicting values.

Installation

To install, follow the usual steps:

  1. Configure SCRIPTS_ROOT in configuration.py
  2. Copy the module examples/custom-scripts/DNS_IPAM_Updater.py containing the scripts to the directory specified in SCRIPTS_ROOT

Warning

These scripts are provided as they are. They have not been thoroughly tested and may corrupt your NetBox database, including IP Address and NetBox DNS objects. Use at your own risk as a basis for your own experiments. You better have a backup.

As always, feedback is welcome!

Have a nice evening,

Pete.

Thank you very much for your work. I will work through your examples. I hope your work can help others too.
Should i close this issue or will you transform it into a feature-request?

Should i close this issue or will you transform it into a feature-request?

As currently I'm in discussions about how an integration with IPAM could and should look like (the longer you think about it the less obvious the whole issue turns out to be), it'd difficult to formulate a sensible feature request ... so if you don't mind it would be OK to close it. On the other hand, as soon as PR #285 is merged it will be closed anyway.

I should have tested a bit more as it turned out ... updating the IPAM 'DNS Name' stuff was not really working well. This is fixed now.