My below code is getting ivp6 ip address am not sure how to get ipv4 in the same manner.
string ipAddress = "";
if (Dns.GetHostAddresses(Dns.GetHostName()).Length > 0)
{
ipAddress = Dns.GetHostAddresses(Dns.GetHostName())[0].ToString();
}