NetBox DNS Use Cases #10
Replies: 1 comment
-
DNS provisioning with Ansible and NetBox DNSLet me try to describe the boilerplate architecture I'm currently using for DNS automation with NetBox DNS. I think it's fairly common, but maybe it's not so obvious to other users approaching the issue. DNS ArchitectureThe architecture of the DNS environments I maintain is usually more or less the same:
The hidden master is the only instance dealing with zone files, while the slave servers need the zone information for the configuration files. The resolvers only get the addresses of the slave servers to forward requests to. In some cases the BIND servers are configured to use different zones for usually two views in a split horizon configuration, mostly to differentiate between the zones served to nodes in the internal network and the zones served to the Internet. AutomationAutomation is done using Ansible. This means both the automation of the name server and resolver setup as such and the automation of the provisioning of the data served by the DNS infrastructure. The code listed below is provided as an example. It is not complete, does not contain any site-specific information and will not apply to a different Linux distribution, a different infrastructure, or generally any setup it was not created to work with. It contains, however, the most relevant parts needed to create a solution that will. Infrastructure Setup AutomationThe setup of the infrastructure itself (hidden master, slaves and resolvers) is currently not driven by NetBox. This is the point where the discussion started @LuPo in #248 kicks in, as some parts of the infrastructure such as IP ranges, TSIG authentication etc. associated with DNS, but in varying degrees depending on the tools and the architecture used, are not currently something NetBox DNS deals with. Currently, the infrastructure is maintained in some YAML files that Ansible uses when provisioning. An example of such a configuration file is this:
Here internal name servers are authenticated to accessing the views they are allowed to see via TSIG keys, while external slave servers and resolvers are identified by IP addresses or ACLs. DNS Provisioning AutomationThis part is where the data maintained in NetBox DNS come in. While the infrastructure part is largely static once infrastructure has been set up, the DNS data are highly dynamic and can change fairly often. There are two separate cases that have to be handled: DNS Zone ChangesChanges to DNS Zones (such as the creation or deletion of zones) need to be applied to both the hidden master and the slaves serving views within the affected zones, and in some cases (though that is depending on how much information about the zones the resolvers need) to the resolvers. Confiration files such as
The macros include some boilerplate and the required TSIG keys and ACLs, which are generated from the YAML inventory file, a secure data vault and fixed text blocks. The part that is created from data in NetBox DNS is contained in two variables populated when the Ansible playbook runs:
This is where the Ansible lookup Based on these building blocks, the hidden master, the slaves and the resolvers are configured for all views and zones relevant to them. Note that this part of the configuration is only required when there are changes to the zone structure itself, not when only records have been changed. DNS Record ChangesChanges to DNS records are the much more common and, fortunately, much simpler case. Essentially, Ansible needs to create zone files on the hidden master and tell it to reload them, the rest is done by the DNS infrastructure itself. In addition to the information from the
This is all it needs to create a new zone file from this template:
EnhancementsIn many cases it would make sense to move configuration from the YAML files mentioned above to NetBox DNS or another NetBox module. Generally, information that is generic for DNS could be included in NetBox DNS, while information specific to a particular name server implementation would make more sense in a module specific to that name server. One example of the former are TSIG keys, or the information whether a name server is a (hidden) master, a slave or a resolver. TSIG keys, however, are confidential information and should be stored in NetBox secrets (now a separate module), and access configuration to name servers based on TSIG keys, ACLs or addresses is in most cases depending on the implementation and not so generic to the DNS protocol itself. Even views, already implemented in NetBox DNS, are not a standard DNS feature by themselves. They need to be understood as namespaces, and they are so specific to name servers that some implementations (e.g. PowerDNS) don't even have them. There was some discussion whether to call them "views" at all, because that relates to BIND, but nobody came up with a better name. On the other hand, they are a mandatory feature to make it possible for NetBox DNS to keep several zones with the same name, which is a pretty frequent use case. My personal idea for this is to create some additional modules (maybe Then we need to define some enhancements to the NetBox DNS models that make it possible to link that information to DNS zones and views. Such an enhancement would make it possible to model the relations between name servers and resolvers within NetBox DNS. Further InformationFor some more information how to set up NetBox to work with Ansible, please see the code example provided with the plugin. |
Beta Was this translation helpful? Give feedback.
-
I'm starting to move over selected contents from the project's old home at auroraresearchlab/netbox-dns here in case the old repository should go away.
This should not deter anyone from providing their own use cases and examples. Please share what you think could be useful to other members of the community!
Beta Was this translation helpful? Give feedback.
All reactions