/// <summary> /// 判断地址是不是局域网地址 /// </summary> /// <param name="address"></param> /// <returns></returns> public static bool IsLocalAddress(this IPAddress address) { var parts = address.GetIntPart(); if (address.IsA()) { if (parts[0] == 10) { return true; } } if (address.IsB()) { if (parts[0] == 172) { if (parts[1] >= 16 && parts[1]<= 31) { return true; } } } if (address.IsC()) { if (parts[0] == 192 && parts[1] == 168) { return true; } } return false; }