Fully qualified domain name validation

(?=^.{4,253}$)(^((?!-)[a-zA-Z0-9-]{1,63}(?<!-)\.)+[a-zA-Z]{2,63}$) regex is always going to be at best an approximation for things like this, and rules change over time. the above regex was written with the following in mind and is specific to hostnames– Hostnames are composed of a series of labels concatenated with dots. Each label is 1 to 63 characters long, and … Read more

How to find FQDN of local machine in C#/.NET ?

NOTE: This solution only works when targeting the .NET 2.0 (and newer) frameworks. using System; using System.Net; using System.Net.NetworkInformation; //… public static string GetFQDN() { string domainName = IPGlobalProperties.GetIPGlobalProperties().DomainName; string hostName = Dns.GetHostName(); domainName = “.” + domainName; if(!hostName.EndsWith(domainName)) // if hostname does not already include domain name { hostName += domainName; // add the … Read more