标签:str ring ip地址 ips dns 本机 sse 获取本机ip地址 for
IPAddress[] ips = Dns.GetHostAddresses(Dns.GetHostName()); //Dns.GetHostName()获取本机名Dns.GetHostAddresses()根据本机名获取ip地址组
foreach (IPAddress ip in ips)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
{
ip4 = ip.ToString(); //ipv4
}
else if(ip.AddressFamily == AddressFamily.InterNetworkV6)
{
ipv6 = ip.ToString(); //ipv6
}
}
标签:str ring ip地址 ips dns 本机 sse 获取本机ip地址 for
原文地址:http://www.cnblogs.com/lichuangblog/p/8000181.html