为什么我在检查 DNS 时得到如此随机的结果?

发布于 2024-08-28 07:06:57 字数 483 浏览 4 评论 0原文

代码如下:

$domain = "fosajfjdkgdajfhsd.com";
$check1 = checkdnsrr($domain, "MX");
$check2 = checkdnsrr($domain, "A");
$check3 = (checkdnsrr($domain, "MX") || checkdnsrr($domain, "A"));
$check4 = !(checkdnsrr($domain, "MX") || checkdnsrr($domain, "A"));
die("{$check1} - {$check2} - {$check3} - {$check4}");

但是,当我检查输出以查看它返回的内容时,我得到:

 - 1 - 1 - 

该域显然不会存在,所以我不明白为什么检查 A 记录返回 true 而检查 MX 结果不返回根本不给我任何东西。我不明白这里出了什么问题。

The code is as follows:

$domain = "fosajfjdkgdajfhsd.com";
$check1 = checkdnsrr($domain, "MX");
$check2 = checkdnsrr($domain, "A");
$check3 = (checkdnsrr($domain, "MX") || checkdnsrr($domain, "A"));
$check4 = !(checkdnsrr($domain, "MX") || checkdnsrr($domain, "A"));
die("{$check1} - {$check2} - {$check3} - {$check4}");

However when I check the output to see what it's returning, I get this:

 - 1 - 1 - 

The domain obviously wouldn't exist, so I don't understand why checking the A record is returning true and checking the MX result doesn't give me anything at all. I don't understand what's going wrong here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ぇ气 2024-09-04 07:06:57

好吧,浏览完 PHP.net 文档中 checkdnsrr() 的所有示例后,我发现对于 A 记录,您仍然需要附加一个“.”。到域的末尾以便检查它是否有效。我认为 PHP 会自动为你做这样的事情,但不管怎样都行。现在结果符合预期。

Ok, so after browsing through all of the examples in the PHP.net documentation for checkdnsrr() I figured out that for A records you are still required to append a '.' to the end of the domain in order to check it validly. I figured PHP would automatically do that kind of thing for you, but whatever works. Results are as expected now.

唐婉 2024-09-04 07:06:57
$ dig fosajfjdkgdajfhsd.com

; <<>> DiG 9.6.0-APPLE-P2 <<>> fosajfjdkgdajfhsd.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39121
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;fosajfjdkgdajfhsd.com.     IN  A

;; ANSWER SECTION:
fosajfjdkgdajfhsd.com.  0   IN  A   208.69.32.132

;; Query time: 121 msec
;; SERVER: 208.67.222.222#53(208.67.222.222)
;; WHEN: Wed Apr  7 00:59:59 2010
;; MSG SIZE  rcvd: 55

编辑:检查您的 DNS 提供商。如今,很多人都会返回自己的 A 记录,这样如果域名无法解析,他们就可以将广告放在您的眼前。破坏了 DNS,但支付了账单。

$ dig fosajfjdkgdajfhsd.com

; <<>> DiG 9.6.0-APPLE-P2 <<>> fosajfjdkgdajfhsd.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39121
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;fosajfjdkgdajfhsd.com.     IN  A

;; ANSWER SECTION:
fosajfjdkgdajfhsd.com.  0   IN  A   208.69.32.132

;; Query time: 121 msec
;; SERVER: 208.67.222.222#53(208.67.222.222)
;; WHEN: Wed Apr  7 00:59:59 2010
;; MSG SIZE  rcvd: 55

EDIT: Check your DNS provider. Nowadays, lots of them will return their own A record so they can put ads in front of you eyes if the domain can't be resolved. Breaks DNS, but pays the bills.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文