What does the Dns.GetHostEntry (String) method do?

I cannot find in the documentation the correct description of what this actually does.

Does it check for A records or CNAME records, or both?

I understand that in .NET 4, this throws a SocketException if the host does not exist, and this is confirmed by my testing.

+6
source share
2 answers

This is a list of addresses returned

var ips = System.Net.Dns.GetHostEntry("microsoft.com").AddressList; foreach (var ip in ips) Console.WriteLine(ip); // output 64.4.11.37 65.55.58.201 

And these are A records extracted from the query network-tools.com, DNS.

 Answer records microsoft.com A 64.4.11.37 microsoft.com A 65.55.58.201 

So, I would say that he is pulling A.

+7
source

Dns.GetHostEntry built on top of the Windows API and does not use the DNS protocol directly. If IPv6 is enabled, it will call getaddrinfo . Otherwise, it will call gethostbyaddr . These functions can use the local %SystemRoot%\System32\drivers\etc\hosts , DNS, or even NETBIOS file to resolve the host name to an IP address. Resolving a host name to an IP address using DNS will use CNAME records to look up A record.

You can verify this by allowing www.google.com that at least now there is a CNAME record that points to www.l.google.com . Using Dns.GetHostEntry will return the IP addresses from A records for www.l.google.com .

+4
source

Source: https://habr.com/ru/post/917429/


All Articles