auroraresearchlab / netbox-dns

Netbox Dns is a netbox plugin for managing zone, nameserver and record inventory.
MIT License
207 stars 19 forks source link

Added example script for updating DNS from IPAM data and vice versa #285

Closed peteeckel closed 1 year ago

peteeckel commented 1 year ago

fixes #284

This PR contains new example custom scripts for updating IPAM from DNS data and vice versa.

There are two scripts:

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.

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.

peteeckel commented 1 year ago

After some testing I found that the IPAM "DNS Name" updater was fundamentally broken ... fixed some issues with the latest commit.