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:
get ipAddresses of DNS server in registry SYSTEM\CurrentControlSet\Services\Tcpip\Parameter
.
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?
Not answering your question exactly, but as you noted that the aliases are not populated by GetHostEntry - methods Dns.GetHostByName and Dns.Resolve do sort-of populate the Aliases.
It gives what you might call a stupidly incomplete list of aliases -- as far as I can tell, it only adds the alias if the look-up was by name, and that name was the alias.
So basically if the returned host name is different from what you input, then what you input is found to be the alias. The returned Alias value does have the fully qualified name. So this really just seems to be a way to get the fully qualified name of an alias.
You should note that per Microsoft, these methods are both obsolete, as are most of the methods in class Dns.
See also stackoverflow posts
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With