DNS.GetHostEntry()

  • Thread starter The Grim Reaper
  • Start date
T

The Grim Reaper

Hi all,

I have a small "irritant" to do with DNS resolving in .NET Framework v2.0.

For this example, assume the following network information;
Local IP address is 192.168.0.10, on a PC named "PC_01"
Remote address is 192.168.0.20, on a local LAN, and named "PC_02"

DNS.GetHostByAddress("192.168.0.20").Hostname returns "PC_02"
DNS.Resolve("192.168.0.20").Hostname returns "PC_02"

Both these methods are marked obsolete in v2.0 of the framework, and
GetHostEntry is recommended as the replacement. However;

DNS.GetHostEntry("192.168.0.20").Hostname returns "192.168.0.20" .....
not the hostname!!

The only other thing I've noticed is that
DNS.GetHostEntry("192.168.0.10").Hostname returns "PC_01", so it seems to
work on the local node.

Anyone got any idea why!??! Or is it just an annoying bug in
GetHostEntry()?? :(
__________________________________
The Grim Reaper
 
N

NuTcAsE

Try getting the Host entry using the host name... Dns.GetHostEntry
("PC_02"); and see if it returns the right IPAddress. If the IPAddress
returned is different then your DNS server is not mapping 192.168.0.20
as PC_02, or if an exception occurs then the DNS server cannot resolve
the address...

This is not a bug but a behaviour of how DNS lookups are done. IP
address that do not have related DNS records will be returned with the
host name as the ip address provided in the lookup.

Hope this helps...
- NuTcAsE
 
T

The Grim Reaper

I'm afraid that doesn't help! DNS.GetHostEntry("PC_02") definitely returns
the correct IP (and yes, each PC has only one NIC and one IP).
There are no exceptions.
I don't actually know that much about DNS server activity in XP Pro
(although I should! :S)...
Pinging PC_02 returns the text "Pinging PC_02 [192.168.0.20] ...." etc.
I'm pretty sure the network/DNS config is fine.. because as I originally
mentioned, GetHostByAddress() works fine - it's just marked as obsolete in
Framework v2.0.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top