Most reliable way to get fully-qualified domain name of local machine when IPv4 & 6 are configured

Go To StackoverFlow.com

1

I need the FQDN of my local machine (app01.example.com).

Normally, I would use System.Net.Dns.GetHostName(), but if you look at the community content at the bottom of the documentation for Dns.GetHostName(), you'll notice that there's some strange behavior when you're on a machine that has IPv4 & 6 enabled.

I do not have apriori knowledge of whether the servers running my code will have IPv6 configured or not. They will absolutely have IPv4 configured.

Given these constraints, what do you think is the most reliable method for getting the FQDN of my machine?

Reference SO Questions:

2012-04-05 19:28
by John Ruiz
Found this answer as promising: need to test on an IPv6-enabled box - John Ruiz 2012-04-05 19:58


0

Dns.GetHostEntry("localhost").HostName

Someone else posted this here.

2012-10-04 13:30
by Nick
It says in the question that they are NOT using the DNS.GetHostName() method and why - Jesse 2012-10-05 07:08
Ads