简体   繁体   English

如何获取手机的公共IP地址?

[英]How do I get a public IP address of a mobile phone?

I want to connect my phone to a server using the internet using the server's IP address. 我想使用服务器的IP地址使用互联网将手机连接到服务器。 Mobile phone's IP address are normally private as far as I came to know.. To make my app work, I need a public Ip address of my phone. 据我所知,手机的IP地址通常是私人的。为了使我的应用程序正常工作,我需要手机的公共IP地址。 How do I achieve that?? 我该如何实现?

Thanks 谢谢

You'll have to wait for IPv6 ;) Now you get private address and the your service provider does some address translation (NAT): The router has one single public IP and uses ports to map incoming messages to IP addresses of the private network. 您将不得不等待IPv6;)现在您获得私有地址并且您的服务提供商执行一些地址转换(NAT):路由器具有一个单一的公共IP并使用端口将传入消息映射到专用网络的IP地址。

Your mobile's IP is invisible to the internet and the networks public IP is useless, because it is the router's address. 您的移动设备的IP对互联网是不可见的,网络公共IP是无用的,因为它是路由器的地址。 Maybe with IPv6 we have public IPs for all mobiles, but for now you'll have to find a different solution for your problem - public IP doesn't work with mobiles as with all other clients in private networks (behind routers). 也许使用IPv6我们为所有移动设备提供公共IP,但是现在您必须为您的问题找到不同的解决方案 - 公共IP不能像移动设备那样与私有网络中的所有其他客户端一起使用(在路由器后面)。

Setup your own hosting server, make your app "goto" that server, fetch a simple txt page, in that simple txt you dynamically on the server set the address that was used to get the txt. 设置你自己的托管服务器,让你的应用程序“转到”该服务器,获取一个简单的txt页面,在那个简单的txt你动态地在服务器上设置用于获取txt的地址。

Example: 例:

Server: yourexample.com url for /ip.php ip.php just respondes with mimetype text and the address of the requesting client. 服务器:/ip.php的yourexample.com网址ip.php只响应mimetype文本和请求客户端的地址。

J2ME: Request yourexample/ip.php in the repsonse is the address of your app. J2ME:在repsonse中请求yourexample / ip.php是您的应用程序的地址。

You should get your i/p address. 你应该得到你的i / p地址。 Open your browser and enter http://whatismyipaddress.com/ or wait till you have You'll have to wait for IPv6 打开浏览器并输入http://whatismyipaddress.com/或等到有你必须等待IPv6

astonishingly - t-mobile 3g service seems to assign a public IP. 令人惊讶的是,t-mobile 3g服务似乎分配了一个公共IP。 I'm still looking into the details, but I've seen an internet-available website running on a tethered laptop 我仍然在调查细节,但我看到一个可以连接笔记本电脑上运行的互联网网站

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM