反向DNS

维基百科,自由的百科全书

计算机网络中,反向DNS查找反向DNS解析(rDNS)是查询域名系统(DNS)来确定IP地址关联的域名的技术——通常的“转发”的反向DNS查找域名的IP地址。反向DNS查询的过程使用PTR记录。互联网的反向DNS数据库植根于 .arpa 顶级域名。

虽然协议 [rfc:1912 RFC1912年] (第2.1节)建议,“每一个互联网可访问的主机都应该有一个名字”和“每一个IP地址都应该有一个匹配 PTR 记录”,但这并不是一个互联网标准 强制要求,所以并不是每一个IP地址都有一个反向记录。

历史使用情况[编辑]

现代“反向DNS查找”不应被混淆[1],“反向查询”(IQUERY)机制在RFC 1035中写到:

Inverse queries take the form of a single RR in the answer section of the message, with an empty question section. The owner name of the query RR and its TTL are not significant. The response carries questions in the question section which identify all names possessing the query RR which the name server knows. Since no name server knows about all of the domain name space, the response can never be assumed to be complete. Thus inverse queries are primarily useful for database management and debugging activities. Inverse queries are not an acceptable method of mapping host addresses to host names; use the in-addr.arpa domain instead.[2]

IQUERY消息类型总是“可选的”和“从未取得了广泛使用”;“permanently retired”在2002年采用RFC 3425。

实现细节[编辑]

IPv4 反向解析[编辑]

反向解析 IPv4 地址时使用一个特殊的域名 in-addr.arpa。在这个模式下,一个 IPv4 由点号分隔的四个十进制数字串联,并加上一个 .in-addr.arpa 域名后缀。通过将 32 位IPv4地址拆分为四个八位字节,并将每个八位字节转换为十进制数来获得前四个十进制数。不过需要注意的是,在反向 DNS 解析时,IPv4 书写的顺序是和普通 IPv4 地址相反的。

比如,如果要查询 8.8.4.4 这个IP地址的 PTR 记录,那么需要查询 4.4.8.8.in-addr.arpa,结果被指到 google-public-dns-b.google.com 这条记录。

如果 google-public-dns-b.google.com的 A 记录反过来指向 8.8.4.4,那么就可以说这是个带正向确认的反向DNS记录英语Forward-confirmed_reverse_DNS

参考文献[编辑]

  1. ^ RFC 3425 — Obsoleting IQUERY. November 2002 [2017-12-28]. (原始内容存档于2020-10-30). 
  2. ^ RFC 1035 — Domain names - implementation and specification. November 1987 [2017-12-28]. (原始内容存档于2011-02-12).