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:

Community
  • 1
  • 1
John Ruiz
  • 2,211
  • 2
  • 19
  • 29
  • Found [this](http://stackoverflow.com/questions/804700/does-anyone-know-a-way-to-get-the-fqdn-of-local-machine-in-c) answer as promising: need to test on an IPv6-enabled box. – John Ruiz Apr 05 '12 at 19:58

1 Answers1

0
Dns.GetHostEntry("localhost").HostName

Someone else posted this here.

j0k
  • 21,914
  • 28
  • 75
  • 84
Nick
  • 196
  • 1
  • 1
  • 4
  • 1
    It says in the question that they are NOT using the DNS.GetHostName() method and why. – Jesse Oct 05 '12 at 07:08