Dns.GetHostEntry not working
I am using Dns.GetHostEntry(IPAddress) to resolve an IP address to an IPHostEntry instance As Asp.net 2.0 suggested. But is throws no such host is known exception. The code is very simple:
IPHostEntry
oIPHostEntry =Dns.GetHostEntry(m_sHost); It works fine if i using
IPHostEntry
oIPHostEntry =Dns.Resolve(m_sHost); which is obsolete according to MSDN. What is wrong with Dns.GetHostEntry, It seems it doesn't work on Windows 2003 server. Can anybody help with this? Thank you.
If you pass an IP address literal to GetHostEntry it will attempt a DNS reverse resolve instead of just giving you back the IP address. If the data for a successfull reverse resolve is not in your DNS server, this will fail. If you don't want this semantic (ie. no reverse lookup), then use Dns.GetHostAddresses.
Thank you Mike. Is there any performance differnece between Dns.GetHostEntry and Dns.GetHostAddresses? From command line, how do I do reverse DNS lookup? And on DNS server how do I make sure the data for the successfull reverse resolve is on our DNS server? Thank you.
1. As Mike already mentioned the difference between GetHostEntry and GetHostAddresses is that whenever you give an IP address to DnsGetHostEntry it will query the DNS server and try to get the host name for that IP address and then get all the addresses associated with it?: For example
string ip = "10.10.10.10"
Dns.GetHostEntry(ip);
If the reverse lookup is successfull it will return the name of the machine and all IP addresses
Dns.GetHostAddress(ip) will return the same Ip address as the name and then return the IP address as the only address in the host entry address list
2. Reverse lookup from command line:
nslookup [ip address]
3. I have no idea how to put information on the DnsServer. You can search the other forums here http://forums.microsoft.com/MSDN/default.aspx?SiteID=1 for one where you can post server configuration questions
Mariya