.NET Framework Bookmark and Share   
 index > Network Class Library (System.Net) > Chasing DNS Reverse Lookup..
 

Chasing DNS Reverse Lookup..

VC#08

I'm trying to take an IP and do a reverse lookup to find the host name. Originally I was using GetHostByAddress, but it fails with "The requested name is valid and was found in the database, but it does not have the correct associated data being resolved for". I drop to command prompt and it works just fine. So after looking a little, I found the API deprecated, so I went to GetHostEntry, but it always returns the IP as the host name. Can someone please tell me what we are too use.

IPAddress hostIPAddress = IPAddress.Parse(address);
//IPHostEntry ipHostEntry = Dns.GetHostByAddress(hostIPAddress);
IPHostEntry ipHostEntry = Dns.GetHostEntry(hostIPAddress);
return ipHostEntry.HostName;

Chizl.com
Looks fine to me!

IPAddress ipAddress = IPAddress.Parse("66.102.9.104");
IPHostEntry ipHostEntry = Dns.GetHostEntry(ipAddress);
Console.WriteLine("{0} is {1}", ipAddress, ipHostEntry.HostName);

output:
66.102.9.104 is lm-in-f104.google.com

My local IP resolves to my machine name
output:
192.168.0.51 is NelsonMandela

However another local machine's name cannot be resolved:
192.168.0.52 is 192.168.0.52

But that other machine's name is not in my local hosts file so I shouldn't be able to determine the host name.
Wole Ogunremi
Looks fine to me!

IPAddress ipAddress = IPAddress.Parse("66.102.9.104");
IPHostEntry ipHostEntry = Dns.GetHostEntry(ipAddress);
Console.WriteLine("{0} is {1}", ipAddress, ipHostEntry.HostName);

output:
66.102.9.104 is lm-in-f104.google.com

My local IP resolves to my machine name
output:
192.168.0.51 is NelsonMandela

However another local machine's name cannot be resolved:
192.168.0.52 is 192.168.0.52

But that other machine's name is not in my local hosts file so I shouldn't be able to determine the host name.
Wole Ogunremi

I'm on sinus meds today or least that my story and I'm sticking to it.

I didn't realize my host providers DNS has www.chizl.comas the website and chizl.com pointing at my mail server. So they come back with two different IP's andthe reverse lookup on the IP for www.chizl.com comes back with nothing where the one with chizl.com comes back with my hosting provider's name, which seems backwards. I was doing the reverse lookup in the console with chizl.com and using www.chizl.com in the code. Hints the error.

Sorry for taking up your time.

Chizl.com

You can use google to search for other answers

Custom Search

More Threads

• ftpwebrequest/ftpwebresponse :The underlying connection was closed: An unexpected error occurred on a receive and the remote name could not be resolved
• ConnectAsync doesn't work with datagram sockets?
• Couldn't connect to remote server
• NetworkCredentials failed to work after setting network security
• An established connection was aborted by the software in your host machine
• Possible Get Response Stream truncation
• Bypass choose digital certificate window
• Using NetworkInterface::PhysicalAddress
• GetResponse() Error:Could not establish secure channel for SSL/TLS.
• Originate mail from an external dll