22 lines
533 B
C#
22 lines
533 B
C#
using System.Net;
|
|
using System.Net.Sockets;
|
|
|
|
namespace Aurora.Utils
|
|
{
|
|
public static class IpUtil
|
|
{
|
|
public static string GetLocalIPAddress()
|
|
{
|
|
string returnIp = "";
|
|
var host = Dns.GetHostEntry(Dns.GetHostName());
|
|
foreach (var ip in host.AddressList)
|
|
{
|
|
if (ip.AddressFamily == AddressFamily.InterNetwork)
|
|
{
|
|
returnIp = ip.ToString();
|
|
}
|
|
}
|
|
return returnIp;
|
|
}
|
|
}
|
|
} |