Ex : I want something like abc.hyd.mycompany.com. My requirement is to parse this name and initialize appropriate service.
using System.Net; Dns.GetHostName() // doesn't return fully qualified name it just gives "abc"
You can check the FQDN using hostname --fqdn or the domain name using dnsdomainname. You cannot change the FQDN with hostname or dnsdomainname. Technically: The FQDN is the name getaddrinfo returns for the hostname returned by gethostname.
Type "ipconfig" and press "Enter." This displays the IP address for your Windows server. Use this IP address to view the fully qualified domain name of the server.
You may be able to get the whole DNS string like this:
System.Net.Dns.GetHostEntry("").HostName
We don't have full fledged DNS names where I work, but it does give me a three level faux domain name instead of just the hostname.
Edit 2011/03/17: Incorporated changes suggested by mark below.
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