Do you mix the difference between what DNS says about the name you are trying to resolve using these methods and find out which IP addresses are actually bound to the TCP / IP protocol stack that runs on the particular machine in which you are interested? If you want to know what IP addresses the machine is configured to, regardless of what may or may not be registered in the DNS, you would like to look at using WMI to list the addresses configured on the machine.
See article: WMI Request for IP Address, Domain Name, OS Version
In the above code, you simply ask the local machine that the code is running to use the configured DNS resolver and indicate which records exist as DNS records for the name that you use for the query. This is why you can get the value when you try to query for something like www.google.com. This is because you are simply looking for a name in DNS and, since it is a public name, any properly configured DNS server will be able to report a valid value.
This is very different from what IP addresses can be bound to the server. For example, think of a server sitting behind a firewall. In fact, the server can use IP addresses that are local to the internal network, which map to the public IP addresses on the firewall. In this case, the IP addresses that the server knows about are completely different from the public IP addresses that will be displayed in the corresponding DNS records.
source share