string hostname = Dns.GetHostName();
Console.WriteLine("Hostname: {0}", hostname);
IPAddress[] addresses = Dns.GetHostAddresses(hostname);
foreach (IPAddress addr in addresses)
{
Console.WriteLine("IP Address: {0} ({1})",
addr.ToString(), addr.AddressFamily);
}
Hostname: Ben-Desktop
IP Address: fe80::2c4c:372:e7ee:35b7%14 (InterNetworkV6)
IP Address: fe80::c1aa:9268:a7f0:a203%8 (InterNetworkV6)
IP Address: 192.168.1.2 (InterNetwork)
IP Address: 2001:0:4137:9e50:2c4c:372:e7ee:35b7 (InterNetworkV6)