社区
C#
帖子详情
如何获取对应的外网ip
leikaiwei
2010-10-28 02:29:53
如题
我不要本地ip
要外网的.
但是客户端肯定是内网的用户
用什么方法可以简单的获取呢.?
...全文
85
4
打赏
收藏
如何获取对应的外网ip
如题 我不要本地ip 要外网的. 但是客户端肯定是内网的用户 用什么方法可以简单的获取呢.?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
4 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
leikaiwei2
2010-11-02
打赏
举报
回复
就不给你们分
leikaiwei
2010-11-02
打赏
举报
回复
都考别人的干吗呢.
wuyq11
2010-10-28
打赏
举报
回复
static string GetPage(string url)
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
try
{
using (HttpWebResponse res = (HttpWebResponse)req.GetResponse())
{
using (StreamReader sr = new StreamReader(res.GetResponseStream()))
{
return sr.ReadToEnd();
}
}
}
catch (System.Exception e)
{
return e.Message;
}
finally
{
req.Abort();
}
}
// 通过外部网站得到本机的外部IP
static string GetOuterIP()
{
string patt = @"IP: \[(? <IP>[0-9\.]*)\]";
string url = "";
return Regex.Match(GetPage(url), patt).Groups["IP"].Value;
}
static void Main()
{
foreach (IPAddress ip in Dns.GetHostEntry(Dns.GetHostName()).AddressList)
{
Console.WriteLine(ip);
}
Console.WriteLine();
Console.WriteLine(GetOuterIP());
}
porschev
2010-10-28
打赏
举报
回复
Request.UserHostAddress.ToString()
Android
获取
外网
IP
,城市地址
1.先
获取
外网
IP
: /** *
获取
外网
IP
地址 * * @return */ public void getNet
Ip
() { new Thread() { @Override public void run() { while (status) { URL infoUrl = null;
查询服务器
外网
IP
和根据域名查询
外网
IP
[size=medium] linux经常需要查询服务器的
外网
IP
,或是通过域名来查询该服务器
对应
的
外网
IP
1、查询本地服务器
外网
IP
curl
ip
info.io/
ip
2、通过域名查询
外网
IP
通过执行命令:nslookup www.baidu.com 可得到下面结果 Non-authoritative answer: www.baidu.com...
java
获取
本地
外网
ip
地址
public static String get
IP
() { String
ip
= "http://pv.sohu.com/cityjson?ie=utf-8"; String inputLine = ""; String read = ""; String to
Ip
=""; try { ...
获取
外网
IP
地址API
1、
获取
外网
IP
地址 地址: http://pv.sohu.com/cityjson?ie=utf-8 返回结果: var returnCitySN = {"c
ip
": "39.***.***.***", "cid": "370000", "cname": "山东省"}; 2、
获取
IP
地址详细信息 地址: http://
ip
.taobao.com/service/get
Ip
Info.php?
ip
...
怎样
获取
本机的真实
IP
地址
import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.util.Enumeration; public class Main { public static void main(String[] args) throws
C#
111,129
社区成员
642,535
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章