GetHostByAddr() win32
我给出一个 IP 地址:64.78.58.91,我想使用 GetHostByAddr() win32 API 检索主机名。
它不是返回 www.ripcode.com,而是返回 intermedia.net
我希望得到 www.ripcode.com 你能建议一个不同的 API 来解决这个问题吗?
预先致谢
最诚挚的问候, 苏仁
I am giving an IP Address : 64.78.58.91 and i would like to retrieve the hostname using GetHostByAddr() win32 API.
Instead of returning www.ripcode.com it returns intermedia.net
I would expect to get www.ripcode.com Can you suggest a Different API which could solve this problem.
Thanks in Advance
Best Regards,
Suren
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可能会遇到此行为的几个原因:
从未为 www.ripcode.com 设置 PTR 记录,因此该地址似乎仍然属于 intermedia.net(可能是 www.ripcode.com 的托管提供商) .
同一 IP 地址上托管有多个域,但实际上只有一个 (intermedia.net) 具有 PTR 记录。
设置了多个 PTR 记录,但 GetHostByAddr() 只提供了其中之一。
假设您拥有 www.ripcode.com,并且您拥有该 IP 地址的独占使用权(这不是共享托管设置),您需要联系您的托管提供商并让他们更改 PTR 记录以引用您的域,以便反向 DNS 查找将正常工作。
这对于发送电子邮件尤其重要。 许多电子邮件服务器会对发送服务器的 IP 进行反向查找,并根据发送邮件的域检查该域。 如果它们不匹配,消息通常会被拒绝。
A few reasons why you might get this behavior:
A PTR record was never set up for www.ripcode.com, so the address still appears to belong to intermedia.net (likely the hosting provider for www.ripcode.com).
Multiple domains are hosted on that same IP address, but only one (intermedia.net) actually has a PTR record.
There are multiple PTR records set up, but GetHostByAddr() is only giving you one of them.
Assuming that you own www.ripcode.com, and you have exclusive use of that IP address (it's not a shared hosting setup) you would want to contact your hosting provider and have them change the PTR record to reference your domain so reverse dns lookups will work properly.
This is especially important for sending e-mail. Many e-mail servers will do a reverse lookup on the IP of the sending server and check the domain against the domain sending the mail. If they don't match up, the message will often be rejected.
如果IP地址属于共享主机,它将为许多不同的网站提供服务。 这可能是你能做的最好的事情了。
该过程称为反向 DNS。
If the IP address belongs to a shared host, it will serve many different websites. This may be the best you can do.
The process is called Reverse DNS.
您可以直接使用dns api。 有一个函数 dnsQuery。 请参阅以下链接:
https://support.microsoft.com/en-in/kb/ 831226
https://msdn.microsoft .com/en-us/library/windows/desktop/ms682016%28v=vs.85%29.aspx
you can directly use dns api. There is a function dnsQuery. Please see following links:
https://support.microsoft.com/en-in/kb/831226
https://msdn.microsoft.com/en-us/library/windows/desktop/ms682016%28v=vs.85%29.aspx