0

I inherited code that makes the call to Dns.GetHostEntry("10.1.12.180") (or by using the dns of the machine) and the IPHostEntry that is returned has a different ip address "10.100.160.18" If I run the code on the same subdomain (10.1.12) it works. Another developer using WireShark said he doesn't see the call being made and that I must be overriding the GetHostEntry call to return that specific address (we used to have that address on the network). I'm not overriding the call.

I know that I can circumvent the issue by using IPAddress.Parse() since I do have the correct ip address.

Any ideas why it would return the incorrect ip? It used to work. I have checked with IT and they don't have any mappings to the incorrect IP address. The only difference it that the machine with ip address 10.1.12.180 was updated to windows 10 (from Windows 7).

I have isolated the call so that I have a project that just makes the Dns.GetHostEntry() call.

1 Answers1

0

IPHostEntry returns a list of addresses, not a single IP address. You should iterate IPHostEntry.AddressList to see all of them.

See here for example usage of Dns.GetHostEntry.

Also be aware Windows can override DNS lookups via the hosts file. This is, unfortunately, a common way to hijack DNS lookups on a specific machine.

Zer0
  • 7,191
  • 1
  • 20
  • 34
  • I do get a list however, it is a list of one address which is incorrect. I had not thought of checking the hosts file but it contains no mappings. – Bo Knows Diddley Mar 26 '19 at 17:08