How to get the fully qualified machine name?

  • Thread starter Thread starter kzavalo
  • Start date Start date
K

kzavalo

Is there any way to get the fully qualified machine name?
The System.Net.Dns.GetHostByAddress method used to find the machine
name sometimes returns NetBIOS names and sometimes returns fully
qualified names. This depends on the machine.

In an attempt to always try to get a fully qualified machine name, I
have passed a machine name obtained from either
System.Net.Dns.GetHostByAddress or System.Environment.MachineName
(which might be a NetBIOS name or might be a fully qualified name) and
then pass that to System.Dns.Resolve(). This gives me a
System.Net.IPHostEntry of which I can access its HostName property. If
I start out with a NetBIOS name (which is all I have in some cases from
the other calls), sometimes I can get a fully qualified name back from
this, but sometimes I am still left with the NetBIOS name.

So, the bottom line is that there does not seem to be a sure fire way
to get the fully qualified name, does it?

Klim Zavalo.
 
kzavalo said:
Is there any way to get the fully qualified machine name?
The System.Net.Dns.GetHostByAddress method used to find the machine
name sometimes returns NetBIOS names and sometimes returns fully
qualified names. This depends on the machine.

In an attempt to always try to get a fully qualified machine name, I
have passed a machine name obtained from either
System.Net.Dns.GetHostByAddress or System.Environment.MachineName
(which might be a NetBIOS name or might be a fully qualified name) and
then pass that to System.Dns.Resolve(). This gives me a
System.Net.IPHostEntry of which I can access its HostName property. If
I start out with a NetBIOS name (which is all I have in some cases from
the other calls), sometimes I can get a fully qualified name back from
this, but sometimes I am still left with the NetBIOS name.

So, the bottom line is that there does not seem to be a sure fire way
to get the fully qualified name, does it?

Klim Zavalo.

I don't think the fully qualified name can be considered an attribute of the
system itself - it's a name that other people use to locate the machine so
it depends on how and where it's being accessed from. So basically it will
depend on the way DNS is configured.

What I'm trying to say is that you should question very hard why you want to
know the fully qualified name, bearing in mind that any number of DNS
entries could point to the same box, and that the same FQ name could resolve
to different addresses on different DNS servers (less likely on the public
internet).

Andy
 
Back
Top