SoFunction
Updated on 2025-03-09

Example of obtaining the IP address of the public network in the .net

namespace
{
    public class GetInternetIP
    {
        public static string GetIP()
        {
            using (var webClient = new WebClient())
            {
                try
                {
                    var temp = ("http://iframe./");
                    var ip = (temp, @"\[(?<ip>\d+\.\d+\.\d+\.\d+)]").Groups["ip"].Value;
                    return !(ip) ? ip : null;
                }
                catch (Exception ex)
                {
                    return ;
                }
            }
        }
    }
}