如何查看 PTR 记录?

Dai*_*tsu 35 email spam ptr-record

我需要检查 PTR 记录以确保我拥有的脚本正在发送电子邮件,而这些电子邮件实际上会被我的用户接收并且不会被错误地标记为垃圾邮件。

我知道拥有 IP 范围的 ISP 必须设置 PTR 记录,但我如何检查它是否已经设置?

l0c*_*b0x 53

如果您有Unix 或 Linux,则可以通过在命令提示符下键入以下内容来执行此操作:

dig -x xx.yy.zz.aa
Run Code Online (Sandbox Code Playgroud)

您将获得具有 aa.zz.yy.xx.in-addr.arpa 权限和解析到此地址的服务器的权限的答案。

Windows 中,您可以执行nslookup xx.yy.zz.aa.

您也可以在www.intodns.com 上在线查看并输入您的域...它会在检查反向区域查找的结果时出错。

xx.yy.zz.aa = 您尝试解析的 IP 地址


更新:

使用 dig、nslookup 或 host 时,通常使用不受您控制的 DNS 服务器(例如 Google (8.8.8.8))很有用,这样您就可以从第 3 方那里得到确认信息是正确的。–佐瑞达痛

Zoredache 提出了一个很好的观点。以下是用于测试/解析到外部/外部 DNS 服务器的命令:

Dig(在 Google 的 DNS 服务器 8.8.8.8 上测试反向 DNS):

dig -x zz.yy.xx.aa @8.8.8.8
Run Code Online (Sandbox Code Playgroud)

Host 和 Nslookup(在 Google 8.8.8.8 的 DNS 服务器上测试反向 dns)

nslookup zz.yy.xx.aa 8.8.8.8
host zz.yy.xx.aa 8.8.8.8
Run Code Online (Sandbox Code Playgroud)

  • 使用 dig、nslookup 或 host 时,使用不受您控制的 DNS 服务器(例如 Google (8.8.8.8))通常很有用,这样您就可以从第 3 方获得确认信息是否正确。 (3认同)

pro*_*tdp 16

我知道这已被标记为已回答,但我想提供更全面的答案。对于我的示例,我将使用:

  1. google.com的 IP 地址172.217.3.206因为它确实有 PTR 记录。
  2. serverfault.com的 IP 地址151.101.1.69因为它没有PTR 记录。

首先要注意的dig是多平台命令,您可以在BIND下列出的ISC BIND 网站上获取适用于 Windows 的命令,然后选择您的 Windows 平台(32 位或 64 位)。它还有许多其他工具,包括它自己的 nslookup 二进制文件。我不使用 nslookup.exe 版本,而是使用 Windows 附带的默认版本(C:\Windows\System32\nslookup.exe)。但是,如果您想使用,dig您可能需要编辑您的本地 PATH 环境变量,或将该dig工具移动到您的 C:\Windows\System32 文件夹。

命令 1) dig PTR 206.3.217.172.in-addr.arpa- 传统上,这是用户执行反向 DNS 查找的方式。他们将手动转置 IP 地址:172.217.3.206to 206.3.217.172(注意四个八位字节中的每一个的顺序)并添加in-addr.arpa到字符串的末尾。这是输出:

; <<>> DiG 9.9.5 <<>> PTR 206.3.217.172.in-addr.arpa
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39790
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;206.3.217.172.in-addr.arpa.    IN      PTR

;; ANSWER SECTION:
206.3.217.172.in-addr.arpa. 84300 IN    PTR     sea15s12-in-f206.1e100.net.
206.3.217.172.in-addr.arpa. 84300 IN    PTR     sea15s12-in-f14.1e100.net.
206.3.217.172.in-addr.arpa. 84300 IN    PTR     sea15s12-in-f14.1e100.net.
206.3.217.172.in-addr.arpa. 84300 IN    PTR     sea15s12-in-f206.1e100.net.

;; Query time: 23 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Sun Mar 26 04:20:28 Pacific Daylight Time 2017
;; MSG SIZE  rcvd: 153
Run Code Online (Sandbox Code Playgroud)

命令 2) dig -x 172.217.3.206- 这个版本的命令要简单得多,如 中所述dig -h,该-x标志是“反向查找的快捷方式”。输出与上一个命令中显示的输出相同。

命令 3) dig -x 151.101.1.69- 此示例使用 serverfault.com 示例显示未找到 PTR 记录时的情况。可以看到,答案没有列出PTR,只能找到以下的SOA记录151.in-addr.arpa

; <<>> DiG 9.9.5 <<>> -x 151.101.1.69
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 21854
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;69.1.101.151.in-addr.arpa.     IN      PTR

;; AUTHORITY SECTION:
151.in-addr.arpa.       1786    IN      SOA     pri.authdns.ripe.net. dns.ripe.net. 1490512027 3600 600 864000 3600

;; Query time: 23 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Sun Mar 26 04:30:38 Pacific Daylight Time 2017
;; MSG SIZE  rcvd: 114
Run Code Online (Sandbox Code Playgroud)

命令 4) nslookup 172.217.3.174- 这是用户l0c0b0x在此线程的主要答案中建议的命令。虽然确实有结果,但不清楚这是 PTR 记录还是其他类型的记录。我认为如果给它一个 IP,它默认会返回一个 PTR,但我仍然想确定。如果有多个 PTR,它也会省略其他记录:

Server:  google-public-dns-a.google.com
Address:  8.8.8.8

Name:    sea15s11-in-f14.1e100.net
Address:  172.217.3.174
Run Code Online (Sandbox Code Playgroud)

命令 5) nslookup -debug 172.217.3.174- 使用此命令来查看完整列表,包括记录类型和完整的结果列表。该-debug标志仍然存在,要关闭它,您必须使用-nodebug

------------
Got answer:
    HEADER:
        opcode = QUERY, id = 1, rcode = NOERROR
        header flags:  response, want recursion, recursion avail.
        questions = 1,  answers = 1,  authority records = 0,  additional = 0

    QUESTIONS:
        8.8.8.8.in-addr.arpa, type = PTR, class = IN
    ANSWERS:
    ->  8.8.8.8.in-addr.arpa
        name = google-public-dns-a.google.com
        ttl = 86141 (23 hours 55 mins 41 secs)

------------
Server:  google-public-dns-a.google.com
Address:  8.8.8.8

------------
Got answer:
    HEADER:
        opcode = QUERY, id = 2, rcode = NOERROR
        header flags:  response, want recursion, recursion avail.
        questions = 1,  answers = 4,  authority records = 0,  additional = 0

    QUESTIONS:
        174.3.217.172.in-addr.arpa, type = PTR, class = IN
    ANSWERS:
    ->  174.3.217.172.in-addr.arpa
        name = sea15s11-in-f14.1e100.net
        ttl = 83026 (23 hours 3 mins 46 secs)
    ->  174.3.217.172.in-addr.arpa
        name = sea15s11-in-f174.1e100.net
        ttl = 83026 (23 hours 3 mins 46 secs)
    ->  174.3.217.172.in-addr.arpa
        name = sea15s11-in-f14.1e100.net
        ttl = 83026 (23 hours 3 mins 46 secs)
    ->  174.3.217.172.in-addr.arpa
        name = sea15s11-in-f174.1e100.net
        ttl = 83026 (23 hours 3 mins 46 secs)

------------
Name:    sea15s11-in-f14.1e100.net
Address:  172.217.3.174
Run Code Online (Sandbox Code Playgroud)

命令 6) nslookup -type=PTR 172.217.3.174- 此版本的命令指定带有-type标志的PTR 记录。它-type在两个方面与没有标志的版本不同。首先是它列出了所有 PTR 答案。第二个是它包含了另一个命令忽略包含的信息“非权威答案”。如果您仔细查看上面的调试输出,authority records状态 0,那么这两个命令都应该声明“非权威答案”。

Server:  google-public-dns-a.google.com
Address:  8.8.8.8

Non-authoritative answer:
174.3.217.172.in-addr.arpa      name = sea15s11-in-f14.1e100.net
174.3.217.172.in-addr.arpa      name = sea15s11-in-f14.1e100.net
174.3.217.172.in-addr.arpa      name = sea15s11-in-f174.1e100.net
174.3.217.172.in-addr.arpa      name = sea15s11-in-f174.1e100.net
Run Code Online (Sandbox Code Playgroud)

命令 7) nslookup -debug -d2 -type=PTR 151.101.1.69- 以下是如何获得有关完整反向查找请求的尽可能多的详细信息。提醒:要关闭它,请使用-nodebug-nod2。此示例故意在 serverfault.com 示例上失败:

------------
SendRequest(), len 38
    HEADER:
        opcode = QUERY, id = 1, rcode = NOERROR
        header flags:  query, want recursion
        questions = 1,  answers = 0,  authority records = 0,  additional = 0

    QUESTIONS:
        8.8.8.8.in-addr.arpa, type = PTR, class = IN

------------
------------
Got answer (82 bytes):
    HEADER:
        opcode = QUERY, id = 1, rcode = NOERROR
        header flags:  response, want recursion, recursion avail.
        questions = 1,  answers = 1,  authority records = 0,  additional = 0

    QUESTIONS:
        8.8.8.8.in-addr.arpa, type = PTR, class = IN
    ANSWERS:
    ->  8.8.8.8.in-addr.arpa
        type = PTR, class = IN, dlen = 32
        name = google-public-dns-a.google.com
        ttl = 86280 (23 hours 58 mins)

------------
Server:  google-public-dns-a.google.com
Address:  8.8.8.8

------------
SendRequest(), len 43
    HEADER:
        opcode = QUERY, id = 2, rcode = NOERROR
        header flags:  query, want recursion
        questions = 1,  answers = 0,  authority records = 0,  additional = 0

    QUESTIONS:
        69.1.101.151.in-addr.arpa, type = PTR, class = IN

------------
------------
Got answer (103 bytes):
    HEADER:
        opcode = QUERY, id = 2, rcode = NXDOMAIN
        header flags:  response, want recursion, recursion avail.
        questions = 1,  answers = 0,  authority records = 1,  additional = 0

    QUESTIONS:
        69.1.101.151.in-addr.arpa, type = PTR, class = IN
    AUTHORITY RECORDS:
    ->  151.in-addr.arpa
        type = SOA, class = IN, dlen = 48
        ttl = 1787 (29 mins 47 secs)
        primary name server = pri.authdns.ripe.net
        responsible mail addr = dns.ripe.net
        serial  = 1490512027
        refresh = 3600 (1 hour)
        retry   = 600 (10 mins)
        expire  = 864000 (10 days)
        default TTL = 3600 (1 hour)

------------
*** google-public-dns-a.google.com can't find 69.1.101.151.in-addr.arpa.: Non-ex
istent domain
Run Code Online (Sandbox Code Playgroud)

命令 8) nslookup 174.3.217.172.in-addr.arpa- 您可能想知道是否可以使用传统的反向 DNS 查找方法,nslookup就像我们在命令 1 中使用dig. 你可以。请注意与我上面列出的相同 nslookup 失败(命令 6)在此命令和-type=PTR下面设置了标志的命令(命令 9)之间:

Server:  google-public-dns-a.google.com
Address:  8.8.8.8

Name:    174.3.217.172.in-addr.arpa
Run Code Online (Sandbox Code Playgroud)

命令 9) nslookup -type=PTR 174.3.217.172.in-addr.arpa- 正如您所料,它看起来与命令 6 相同。

Server:  google-public-dns-a.google.com
Address:  8.8.8.8

Non-authoritative answer:
174.3.217.172.in-addr.arpa      name = sea15s11-in-f14.1e100.net
174.3.217.172.in-addr.arpa      name = sea15s11-in-f14.1e100.net
174.3.217.172.in-addr.arpa      name = sea15s11-in-f174.1e100.net
174.3.217.172.in-addr.arpa      name = sea15s11-in-f174.1e100.net
Run Code Online (Sandbox Code Playgroud)