'in-addr.arpa' in DNS
Published: July 24, 2024
Tags:
Doing a reverse DNS lookup is a common task, where you find out which domain is associated with this ip. This is done by querying the PTR record of the ‘in-addr.arpa’ domain. This domain is used for reverse DNS lookups, mapping IP addresses back to domain names. Here’s how it works:
Sample reverse DNS lookup
|
|
Here we see
|
|
Now question comes where does ‘in-addr.arpa’ come from ?
The ‘in-addr’ part stands for “inverse address,” indicating its role in reverse address mapping The use of “in-addr.arpa” is defined by various internet standards (RFCs).
One of oldest RFC from ‘Nov 1987’ RFC 1035 which defines the DNS protocol and its operations. Here is the excerpt from section 3.5
```
The Internet uses a special domain to support gateway location and
Internet address to host mapping
...
Thus data for Internet address 10.2.0.52 is located at
domain name 52.0.2.10.IN-ADDR.ARPA.
...
```
So utility like dig reverse the IP address and append it to ‘in-addr.arpa’ to get the domain name.
Below is the code snippet from bind9 source code which also hosts the dig utility. This code is used to do reverse DNS lookup.
Snnippet from bind9 source code which has ‘dig’ utility
Snippet from https://gitlab.isc.org/isc-projects/bind9/-/blob/main/bin/dig/dig.c#L2831
|
|
This code snippet is from the get_reverse
https://gitlab.isc.org/isc-projects/bind9/-/blob/main/bin/delv/delv.c#L1783
|
|
To summarise:
When an IPv4 address like 192.0.2.1
needs to be resolved back to a domain name,
- It is reversed then
- Appended with ‘in-addr.arpa’, resulting in
1.2.0.192.in-addr.arpa
. - DNS query is then made for this domain to retrieve the PTR record, which provides the domain name associated with the IP address.
Q: Who manages the ‘in-addr.arpa’ domain?
Hierarchical like the normal DNS.
- IANA(Internet Assigned Numbers Authority) oversees the top-level delegation(i.e. in-addr.arpa).
- RIRs(Regional Internet Registries) manage portions of the namespace within their regions.
- ISPs and organizations manage reverse DNS for their allocated IP address ranges, creating PTR records within the appropriate ‘in-addr.arpa’ subdomains.
Q: What about private IP addresses and reverse DNS?
A: For private IP address blocks (such as 10.0.0.0/8
, 172.16.0.0/12
, 192.168.0.0/16
), reverse DNS is managed internally within the organization.
You can also do dig -x 192.168.2.1
or dig 1.2.168.192.in-addr.arpa PTR
manually to check the reverse DNS for private IP addresses.
Q: What about IPv6 reverse DNS?
Similar to IPv4, IPv6 addresses are also mapped back to domain names using the ‘ip6.arpa’ domain. The process is similar, but the domain name is constructed differently due to the longer address length of IPv6.
Doing dig -x 2001:0db8::1
or dig 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa. PTR
It will help me to improve/learn.