C# 通过ipify接口获取外网IP地址
using (var client = new WebClient())
{
client.Encoding = Encoding.UTF8;
string serviceAddress = "https://api.ipify.org/?format=json";//请求URL地址
var data = client.DownloadString(serviceAddress);
var obj = JsonConvert.DeserializeObject<JObject>(data);
string s = obj["ip"].ToString();
Console.Write(s);
}