Feature #1559

Templated PTR Records to support RFC2317 style classless reverse delegation

Added by Andreas Rogge over 10 years ago. Updated almost 6 years ago.

Target version:
Bugzilla link:
Pull request:
Fixed in Releases:
Found in Releases:


Instead of just creating the DNS PTR by reversing the IP and appending "" it should be possible to create custom strings with templates.

If you only get a fraction of a /24 you can get your reverse-zone delegated as described in RFC2317. This makes crafting your PTR a special case - eventually the PTR syntax is site specific

i.e. your network is and you agree with your ISP to use RFC2317 method 1.
Your ISP will add the following RRs in his Nameserver:

128/ IN NS
128/ IN NS IN CNAME 128.128/ IN CNAME 128.129/ IN CNAME 128.130/
[...] IN CNAME 255.130/

Thus you will have to fill your hosts into the zone 128/ and the PTRs will have to look like
138.128/ IN PTR my-server.domain.tld.
254.128/ IN PTR my-other-server.domain.tld.

Eventually I'd suggest to allow people to add a "PTR-Template" to their subnet configuration where you have variables for the dotted quad, the reversed dotted quad and every byte of the dotted quad.
A template for the above might look like "<% @ip4 %>.128/" and would be configured on subnet

Related issues

Related to Foreman - Tracker #5409: DNS Proxy ImprovementsNew


#1 Updated by Ohad Levy over 6 years ago

#2 Updated by Andreas Rogge almost 6 years ago

When #17037 is merged this can be done finally.
I'm going to have a look how to do it and maybe come up with a patch.

#3 Updated by Andreas Rogge almost 6 years ago

I had a look at what needs to be done to implement this.

AFAICT the following changes are required:
- we need a new optional field `ptr_template` in `Subnet`
- subnet html template needs to be changed to allow to edit the ptr template
- `Subnet` needs a new function `to_arpa(ip)` that renders the ptr according to the template provided if any or otherwise just call `` / ``
- `to_arpa()` in `Net::DNS::PTR4Record#to_arpa` and `Net::DNS::PTR6Record#to_arpa` need to be patched to call `Subnet.subnet_for(ip).to_arpa(ip)` to determine the ptr

I'm somewhat unsure when it comes to calling Subnet.subnet_for(ip) as the function looks rather expensive. Maybe it is better to pass down the subnet object down, but I have absolutely no idea how to do that.

Also available in: Atom PDF