# 反向DNS查询

反向DNS查询是一种DNS查询，它从[IP地址](https://www.edgepedia.org/zh/ip-address)开始，返回与该地址关联的域名，与将名称映射到地址的普通（正向）查询相反。结果承载在存储于.arpa顶级域下特殊区域中的指针（PTR）记录中：IPv4使用in-addr.arpa，IPv6使用ip6.arpa。<sup>[1](https://www.rfc-editor.org/info/rfc1035/)</sup><sup> • </sup><sup>[2](https://www.rfc-editor.org/rfc/rfc3596.html)</sup><sup> • </sup><sup>[3](https://www.cloudflare.com/en-au/learning/dns/dns-records/dns-ptr-record/)</sup>

| 关键事实 | 详情 |
|---|---|
| 作用 | 使用PTR记录将IP地址映射到域名，是A记录的逆操作<sup>[3](https://www.cloudflare.com/en-au/learning/dns/dns-records/dns-ptr-record/)</sup> |
| IPv4命名空间 | in-addr.arpa，定义于RFC 1035（1987年11月）；地址的四个八位组按相反顺序书写，因此10.2.0.52会按52.0.2.10.IN-ADDR.ARPA查询<sup>[1](https://www.rfc-editor.org/info/rfc1035/)</sup> |
| IPv6命名空间 | ip6.arpa，定义于RFC 3596（2003年10月），取代了早期的IP6.INT域；地址以反向的十六进制半字节书写<sup>[2](https://www.rfc-editor.org/rfc/rfc3596.html)</sup> |
| 可选状态 | 配置PTR记录和反向查询区域严格来说是DNS标准实现中的可选部分<sup>[4](https://learn.microsoft.com/en-us/windows-server/networking/dns/reverse-lookup)</sup> |
| 运行重要性 | 许多应用依赖反向查询的及时响应，因此安全稳定地托管in-addr.arpa和ip6.arpa区域对互联网运行至关重要<sup>[5](https://www.rfc-editor.org/rfc/rfc5855.html)</sup> |
| 常见用途 | 电子邮件反垃圾邮件检查，以及将仅有IP的记录转换为人类可读的日志<sup>[3](https://www.cloudflare.com/en-au/learning/dns/dns-records/dns-ptr-record/)</sup> |
| IANA服务目标 | RIR变更请求在300秒内确认、在10分钟内传播到DNS，两项指标的目标均为99.00%<sup>[6](https://www.iana.org/performance/numbers/202607)</sup> |

## 反向查询如何工作

解析器根据地址构造一个特殊名称，并查询该名称的PTR记录。对于IPv4，将点分十进制地址的四个八位组反转，并附加后缀in-addr.arpa。客户端若要查询192.168.1.20处主机的名称，会构造名称20.1.168.192.in-addr.arpa；该反向查询区域的权威服务器会用包含该主机域名的PTR记录作答。<sup>[4](https://learn.microsoft.com/en-us/windows-server/networking/dns/reverse-lookup)</sup> 如果所查询的反向名称无法在本地得到回答，正常的DNS解析（递归或迭代）会定位到对该反向区域具有权威性的服务器，因此解析过程与正向查询相同。<sup>[4](https://learn.microsoft.com/en-us/windows-server/networking/dns/reverse-lookup)</sup>

八位组的反转并非随意为之。从左到右阅读IP地址时，顺序是从网络到主机，而DNS名称的顺序是从一般到具体，因此反转八位组可以让委派的区域恰好对应地址空间中的网络；例如，10.IN-ADDR.ARPA可以是一个区域，而26.IN-ADDR.ARPA可以是另一个独立区域。<sup>[1](https://www.rfc-editor.org/info/rfc1035/)</sup>

对于IPv6，地址表示为一系列半字节（每个占4比特的十六进制数字），以点分隔并按相反顺序书写，最低位半字节在前，位于ip6.arpa之下。地址4321:0:1:2:3:4:567:89ab会变成b.a.9.8.7.6.5.0.4.0.0.0.3.0.0.0.2.0.0.0.1.0.0.0.0.0.0.0.1.2.3.4.IP6.ARPA。<sup>[2](https://www.rfc-editor.org/rfc/rfc3596.html)</sup> 由于每个半字节都是一个独立标签，完整的IPv6反向名称很长；对于区域0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa中的地址2001:DB8::5，记录所有者名称为5.0.0.0.0.0.0.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。<sup>[7](https://developers.cloudflare.com/dns/additional-options/reverse-zones/)</sup>

## PTR记录

PTR记录将IP地址映射到相应域名，其数据字段是一个指向域名空间中某个位置的域名；与CNAME不同，它不意味着别名处理。<sup>[1](https://www.rfc-editor.org/info/rfc1035/)</sup><sup> • </sup><sup>[8](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/ResourceRecordTypes.html)</sup> PTR记录存储在反转后的IP地址之下，并加上.in-addr.arpa，因此192.0.2.255的记录存储在255.2.0.192.in-addr.arpa之下。<sup>[3](https://www.cloudflare.com/en-au/learning/dns/dns-records/dns-ptr-record/)</sup>

运行指导长期以来要求两个方向保持一致。RFC 1912建议每个IP地址在in-addr.arpa域中都有匹配的PTR记录，多宿主主机的所有地址都有PTR记录，并且PTR记录应指回有效的A记录，而不是CNAME别名。<sup>[9](https://datatracker.ietf.org/doc/rfc1912/)</sup>

## 委派与管理

反向区域通过与正向区域相同的层级结构进行委派。控制自己IP前缀的运营者会创建反向区域，使用最低有效八位组作为子域添加PTR记录，并在其区域互联网注册管理机构（RIR）注册该区域的名称服务器。<sup>[7](https://developers.cloudflare.com/dns/additional-options/reverse-zones/)</sup> 对于小于完整/24的前缀，RFC 2317（也称为BCP 20）描述了一种为少于256个地址的IPv4范围委派in-addr.arpa子域的方法。<sup>[10](https://www.rfc-editor.org/info/rfc8686/)</sup>

在顶层，IANA管理.arpa域，即“地址与路由参数区域”，在[互联网架构委员会](https://www.edgepedia.org/zh/internet-architecture-board)的指导下与互联网技术社区合作，专用于互联网基础设施目的；in-addr.arpa被指定用于将IPv4地址映射到域名，ip6.arpa用于IPv6。<sup>[11](https://www.iana.org/domains/arpa)</sup> 区域互联网注册管理机构通过API提交对反向DNS记录的修改，IANA将这些修订传播到DNS中。其公布的服务目标为：API在300秒内确认，DNS在10分钟内传播，两项指标均有99.00%的时间达标，API服务器和DNS分发可用性至少为99.00%；在2026年7月报告中，两项可用性指标均为100%。<sup>[6](https://www.iana.org/performance/numbers/202607)</sup> as112.arpa区域专门用于吸收反向IP地址查询及其他应用的DNS流量。<sup>[11](https://www.iana.org/domains/arpa)</sup>

## 用途

**电子邮件与反垃圾邮件。** 一些电子邮件反垃圾邮件过滤器使用反向DNS检查发件地址的域名，并判断相关IP地址是否很可能属于合法邮件服务器；缺少或错误的PTR记录可能导致电子邮件服务阻止某个域的邮件。历史上，PTR记录可防止出站SMTP服务器被垃圾邮件过滤器阻止，不过SPF、DKIM和DMARC记录现在能更好地验证域所有权。<sup>[3](https://www.cloudflare.com/en-au/learning/dns/dns-records/dns-ptr-record/)</sup><sup> • </sup><sup>[7](https://developers.cloudflare.com/dns/additional-options/reverse-zones/)</sup> 云服务提供商在此基础上进一步发展：Amazon EC2建议为用于发送电子邮件的弹性IP地址分配静态反向DNS记录，并要求在创建反向记录之前先有匹配的正向A记录。<sup>[12](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Elastic_Addressing_Reverse_DNS.html)</sup>

**日志记录与诊断。** 系统日志通常只记录IP地址，反向DNS查询会将其转换为域名，使日志更易于人类阅读；PTR记录还有助于为路由追踪和安全工具填充可读名称。<sup>[3](https://www.cloudflare.com/en-au/learning/dns/dns-records/dns-ptr-record/)</sup><sup> • </sup><sup>[7](https://developers.cloudflare.com/dns/additional-options/reverse-zones/)</sup>

**隐私暴露。** 反向查询也可能泄露信息。观察到某个正在使用的地址的对手可以检索PTR记录，从而获得该计算机的主机名或完全限定域名；由于NAT的普遍存在，这种检索在许多IPv4网络中可能没有用，但在IPv6网络中可能奏效，RFC 8117讨论了将随机化主机名作为补救措施。<sup>[13](https://www.rfc-editor.org/rfc/rfc8117.html)</sup>

## 实际查询

标准DNS查询工具dig为此提供了一种快捷方式：给定-x标志和一个地址，它会自行构造形如94.2.0.192.in-addr.arpa的名称，并将其作为IN类中的PTR记录进行查询；对于IPv6，地址在IP6.ARPA域中以半字节格式查询。例如，dig -x 192.0.2.1会查询该地址的主机名。<sup>[14](https://manpages.debian.org/testing/dnsutils/dig.1.en.html)</sup><sup> • </sup><sup>[15](https://manpages.debian.org/trixie/bind9-dnsutils/dig.1.en.html)</sup>

否定回答遵循一般DNS缓存规则。RFC 8020阐明，NXDOMAIN响应意味着被拒绝的名称及其下的所有名称都不存在，因此收到针对某个反向名称的NXDOMAIN响应的解析器可以将该名称下的整个子树视为不存在，从而减少对权威服务器的不必要查询。<sup>[16](https://www.rfc-editor.org/info/rfc8020/)</sup>

## References

1. [RFC 1035: Domain Names - Implementation and Specification, RFC Editor](https://www.rfc-editor.org/info/rfc1035/)
2. [RFC 3596: DNS Extensions to Support IP Version 6, RFC Editor](https://www.rfc-editor.org/rfc/rfc3596.html)
3. [What is a DNS PTR record?, Cloudflare Learning Center](https://www.cloudflare.com/en-au/learning/dns/dns-records/dns-ptr-record/)
4. [DNS Reverse Lookups in Windows and Windows Server, Microsoft Learn](https://learn.microsoft.com/en-us/windows-server/networking/dns/reverse-lookup)
5. [RFC 5855: Name Servers for IN-ADDR.ARPA and IP6.ARPA, RFC Editor](https://www.rfc-editor.org/rfc/rfc5855.html)
6. [Number Resource Performance Report, July 2026, IANA](https://www.iana.org/performance/numbers/202607)
7. [Reverse zones and PTR records, Cloudflare DNS docs](https://developers.cloudflare.com/dns/additional-options/reverse-zones/)
8. [Supported DNS record types, Amazon Route 53 Developer Guide](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/ResourceRecordTypes.html)
9. [RFC 1912: Common DNS Operational and Configuration Errors, IETF Datatracker](https://datatracker.ietf.org/doc/rfc1912/)
10. [RFC 8686: ALTO Cross-Domain Server Discovery (describing RFC 2317/BCP 20), RFC Editor](https://www.rfc-editor.org/info/rfc8686/)
11. [.ARPA Domain, IANA](https://www.iana.org/domains/arpa)
12. [Create a reverse DNS record for email on Amazon EC2, AWS documentation](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Elastic_Addressing_Reverse_DNS.html)
13. [RFC 8117: Harmful Hostname Practice, RFC Editor](https://www.rfc-editor.org/rfc/rfc8117.html)
14. [dig(1) man page, Debian dnsutils](https://manpages.debian.org/testing/dnsutils/dig.1.en.html)
15. [dig(1) man page, Debian bind9-dnsutils](https://manpages.debian.org/trixie/bind9-dnsutils/dig.1.en.html)
16. [RFC 8020: NXDOMAIN - There Really Is Nothing Underneath, RFC Editor](https://www.rfc-editor.org/info/rfc8020/)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 网络与安全 › 网络基础与架构 › 路由与寻址 › 名称寻址与DNS

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/reverse-dns-lookup

English original: https://www.edgepedia.org/reverse-dns-lookup
