Get IPv4 adress?

As the title says, How can i get the machines iPv4 adress in Unity? I prefer C# if possible :slight_smile: And sorry if this question already exists but I can not search in Unity Answers, I just get a Time Out (504).

var firstIPv4Address = Dns.GetHostEntry(β€œanswers.unity3d.com”).AddressList.FirstOrDefault(a => a.AddressFamily == AddressFamily.InterNetwork);

If you need it for local machine, then replace host name with Dns.GetHostName(). And don’t forget to handle exceptions, especially SocketException.

Depending on the state of your code, you may be able to use

Network.player.ipAddress

This will give you the server IP if running as a server, or the client IP if running as a client.