djbdns and RFC2317 addresses

TL;DR: IPv4 reverse DNS delegations are hard for small network segments, okay?


dn42 is an overlay network running over VPN links which simulates the public internet (both organisationally and functionally) on a much smaller scale. Like the public internet (known as clearnet to dn42), one can register autonomous system numbers, address space and DNS names. Then, you can set up a router and find peers (mostly by asking on the IRC channel) with whom you establish a VPN link over which you can announce your routes using BGP.

It's a great way to learn about internet technologies like BGP and the organisational structure of the public internet. There is also the advantage that if you mess something up, you aren't going to get a big registry like RIPE or ARIN angry at you. The most that will happen is that one of the denizens politely asks you why your network is doing something strange (like passing traffic originating from private address space which isn't routable on dn42 - this has happened to me!).

The address space used internally is the IPv4 private address range and the IPv6 Unique Local Address range fd00::/8. Since there isn't exactly a lot of IPv4 address space available (simulated resource depletion, anyone?), most people take allocations much smaller than /24 (this is important!).

dn42 has its own internal hierarchical DNS system (for the top-level domain .dn42) under which one can register domains through the registry. Once you have a domain and a nameserver set up, you can add a nameserver attribute to you IP address ranges so that reverse DNS lookups get delegated to your nameserver.

IPv4 reverse DNS

For IPv4, if you wish to turn a network address into a symbolic name, you ask a nameserver for the PTR record associated with that address. For example, if you want to turn into a domain name, you query for the PTR record of and get an answer of Now, if you have an IPv4 address range of e.g., then the root servers will delegate the domain to your nameserver. If you have a bigger address range, there are more delegations i.e. the owner of would have and delegated to their nameserver by the root servers. This breaks for smaller address allocations, as the smallest unit of subdivision in IPv4 reverse DNS is the /24 network, so it's impossible to delegate the reverse DNS lookups for a /25 or smaller network.

Turns out there's a way around this. Turns out there's a standardised way around this, by the name of RFC 2317. The solution is to create a domain representing the entire subnetwork (which is delegated to that subnetwork) and then indirect all PTR queries to that domain representing the subnet. That explanation isn't nice to get your head around, so let's have some examples:

You have the IPv4 segment You have two usable IP addresses in this range, and In order to set up reverse DNS for your IP addresses, the administrator of the creates a new domain to represent your subnetwork allocation: 4/ This domain is delegated to your nameserver. Now, the administrator creates CNAME records for each of your IP addresses that fall into their zone which point to subdomains of the domain which represents your subnetwork, i.e. points to 5.4/ and points to 6.4/ You then configure PTR records for those two domains on your nameserver pointing to the desired hostnames.


I like djbdns a lot, and I use it everywhere I need a domain server (DNS caching on my laptop, authoritative nameserver for, etc). However, some manual intervention is required to make IPv4 reverse DNS properly in the aforementioned case.

I have some IPv4 address space in dn42, and I also have a .dn42 domain name. Normally with djbdns, when you tell it about an IPv4 address, it will publish a matching PTR record.

# This record in a tinydns data file creates an A record and a PTR record

# The above line is equivalent to the two following lines

However, my dn42 allocation is a /29. This means that I have to tell tinydns to accept delegations for the subnetwork domain and then specify all the PTR record manually, a bit like this:

# I have, so I must accept the appropriate rDNS delegation and point it to my nameserver

# Now the PTR record

Another case of IPv4 making life hard?