Hi you can follow the below steps to find public ip programmatically
public string GetLanIPAddress()
{
//Get the Host Name
string stringHostName = Dns.GetHostName();
//Get The Ip Host Entry
IPHostEntry ipHostEntries = Dns.GetHostEntry(stringHostName);
//Get The Ip Address From The Ip Host Entry Address List
IPAddress[] arrIpAddress = ipHostEntries.AddressList;
return arrIpAddress[arrIpAddress.Length - 1].ToString();
}
//Get The Lan Ip Address
string strLanIpAddress = GetLanIPAddress();
If you want to check public ip address you can visit this site
Ip-details.com