Multiple IP addresses may be available on the computer. How to find out all your fully qualified domain names (fqdn)?
Update:
I tried the following:
IPHostEntry he = Dns.GetHostEntry(Environment.UserDomainName); foreach (IPAddress ipAddress in he.AddressList) { string x = ipAddress.ToString(); string y = Dns.GetHostEntry(ipAddress.ToString()).HostName; }
I have a machine with two IP addresses, ping, using their fqdn, returns the correct IP addresses. However, the code above always returns me one fqdn of the first IP.
My setup is as follows:
IP1:
123.123.123.123
Name1
IP2:
456.456.456.456
Name2
Both ping and nslookup return the correct value.
The problem is that both lines
Dns.GetHostEntry("123.123.123.123").HostName; Dns.GetHostEntry("456.456.456.456").HostName;
returns "Name1" (instead of "Name1" and "Name2").
However codes
Dns.GetHostEntry("Name1").HostName; Dns.GetHostEntry("Name2").HostName;
work correctly.
source share