shtriha shtriha - 8 months ago 48
C# Question

How to get DNS aliases of specified host name?

I am tying to get information about DNS aliases of specified host name.
I used :

IPHostEntry hostEntry = Dns.GetHostEntry("hostname")

Unfortunately as mentioned in MSDN:

The Aliases property of the IPHostEntry instance returned is not populated by this method and will always be empty.

I plan to get DNS aliases such way:

  1. get ipAddresses of DNS server in registry

  2. use DNS WMI provider to get CNAME records in the DNS server. But in this case permissions for access to the DNS server are requiered.

Is my plan correct?
Is there another way to get CNAME records without permission to DNS server?

Answer Source

Worth noting about the DNS Lookup project is it got a secondary class called DnsProvider which provides the "proper" way of getting the DNS servers from the system without using the registry.

See for more info on that.