Smart way to get the public Internet IP address/geo loc

后端 未结 9 2052
野趣味
野趣味 2021-01-01 05:41

I have a computer on the local network, behind a NAT router. I have some 192.168.0.x addresses, but I really want to know my public IP address, not somethin

9条回答
  •  清酒与你
    2021-01-01 06:30

    Below code will help you to take public IP address

        string _externalIP;
        _externalIP = (new WebClient()).DownloadString("http://http://icanhazip.com/");
        _externalIP = (new Regex(@"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"))
                     .Matches(externalIP)[0].ToString();
    

提交回复
热议问题