**Problem**
Right now the sre.dns.netbox cookbook generates numerous different files which ultimate go into ///etc/gdnsd/zones/netbox/// on auth dns servers. Each of these needs to have an INCLUDE statement pointing to it in the static zone files we create in the [[ https://gerrit.wikimedia.org/r/admin/repos/operations/dns | dns repo. ]] This is extremely cumbersome, tedious and error-prone, especially for IPv6 reverses where we have a separate file for every single link on the Network (as each have their own /64 subnet).
Right now, for instance, our zone files have entries like this:
```
cmooney@dns3003:/etc/gdnsd/zones$ tail -7 0.8.c.e.2.0.a.2.ip6.arpa
; cr2-magru <-> asw1-b4-magru (2a02:ec80:700:fe09::/64)
$ORIGIN 9.0.e.f.0.0.7.0.@Z
$INCLUDE netbox/9.0.e.f.0.0.7.0.0.8.c.e.2.0.a.2.ip6.arpa
; Magru network loopbacks (2a02:ec80:700:ffff::/64)
$ORIGIN f.f.f.f.0.0.7.0.@Z
$INCLUDE netbox/f.f.f.f.0.0.7.0.0.8.c.e.2.0.a.2.ip6.arpa
```
The contents of each of the included files, generated by Netbox, only have the PTR (or A / AAAA) records that go under that $ORIGIN:
```
cmooney@dns3003:/etc/gdnsd/zones$ cat ./netbox/9.0.e.f.0.0.7.0.0.8.c.e.2.0.a.2.ip6.arpa
1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 1H IN PTR et-0-0-2.cr2-magru.wikimedia.org.
2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 1H IN PTR et-0-0-50.asw1-b4-magru.wikimedia.org.
```
**Proposal**
What I would propose is we change how we do things as follows:
* For each zone file we are authoritative for we should have a single INCLUDE statement for netbox entries
* The INCLUDE should be at the zone 'apex' (i.e. $ORIGIN @Z)
* The single file it points to should have all the records that Netbox knows about under that zone
* We just place DNS records in the snippets, with the full label relative to the parent zone, instead of using $ORIGIN statements within the snippets
**/etc/gdnsd/zones/0.8.c.e.2.0.a.2.ip6.arpa:**
```
@ 1H IN SOA ns0.wikimedia.org. hostmaster.wikimedia.org. 2024041716 12H 2H 2W 1H
; Name servers
@ 1D IN NS ns0.wikimedia.org.
@ 1D IN NS ns1.wikimedia.org.
@ 1D IN NS ns2.wikimedia.org.
; Netbox generated entries
$INCLUDE netbox/0.8.c.e.2.0.a.2.ip6.arpa
; Static entries
$ORIGIN x xx x x
yyy IN PTR blah.wikimedia.org
```
**/etc/gdnsd/zones/netbox/0.8.c.e.2.0.a.2.ip6.arpa:**
```
1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.9.0.e.f.0.0.7.0 IN PTR et-0-0-2.cr2-magru.wikimedia.org.
2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.9.0.e.f.0.0.7.0 IN PTR et-0-0-50.asw1-b4-magru.wikimedia.org.
```
The benefit of this approach is we won't ever need to modify the static zone files / dns repo when we add/remove dns_names in Netbox. Right now this is particularly cumbersome for IPv6 reverse ranges.
**Details**
There are a few things we need to consider:
# How does Netbox know what the parent zones are?
## We can list the files in the `templates` dir of the dns repo to find them (or `/etc/zones` on authdns servers)
Interested to get people's thoughts on this. Day to day the current setup is an annoyance, when it comes to doing new sites/DC rows etc. it is a real chore so it would be good to improve things.