Suren
Suren

Reputation:

GetHostByAddr() win32

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

Upvotes: 1

Views: 732

Answers (3)

hilly
hilly

Reputation: 57

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

Upvotes: 0

Eric Petroelje
Eric Petroelje

Reputation: 60498

A few reasons why you might get this behavior:

  1. 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).

  2. Multiple domains are hosted on that same IP address, but only one (intermedia.net) actually has a PTR record.

  3. 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.

Upvotes: 4

Mark Ransom
Mark Ransom

Reputation: 308091

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.

Upvotes: 1

Related Questions