简体   繁体   English

电话的当前IP地址,无论是通过WiFi还是3G连接

[英]Current IP address of phone, whether connected via WiFi or 3G

I need to create a function that returns the current IP address of the phone. 我需要创建一个返回手机当前IP地址的函数。

I found this (but it is only for when the phone is conntected to the WiFi -- I need the address even if it is connected via 3G) http://blog.zachwaugh.com/post/309927273/programmatically-retrieving-ip-address-of-iphone 我发现了这一点(但这仅适用于手机连接到WiFi的情况-即使通过3G连接也需要地址) http://blog.zachwaugh.com/post/309927273/programmatically-retrieving-ip -address-的-iphone

Further, once I have the IP address, I'd like to find the country that it's from. 此外,一旦有了IP地址,我想找到它的来源国家。

您需要pdp_ip0而不是en0

尝试寻找其他适配器之一,“ en0”是无线网卡,尝试“ en1”

Mapping IP address -> country isn't going to work. 映射IP地址->国家/地区无法正常工作。 Specifically, if the phone is connected to any consumer WiFi base station, it is almost guaranteed that said base station is using NAT (network address translation) to share a single IP amongst connected devices. 具体而言,如果电话连接到任何消费者WiFi基站,则几乎可以保证该基站正在使用NAT(网络地址转换)在连接的设备之间共享单个IP。 Ie you'll see IP addresses that start with 10.0.##.## or 192.168.1.## . 也就是说,您会看到以10.0.##.##192.168.1.##开头的IP地址。

You have to contact an external server to figure out what IP address your device is potentially hiding behind. 您必须与外部服务器联系,以找出设备可能隐藏的IP地址。

Lots of info here (though I know nothing about the company running this). 这里有很多信息 (尽管我对这家公司一无所知)。

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

相关问题 基于Web的方法来确定iPhone是否通过3G或Wifi连接 - Web based method to determine if an iPhone is connected via 3G or Wifi iPhone:通过3G连接时获取IP地址 - IPhone : Obtaining Ip address when connected over 3G 如何使用iPhone / iOS编程(Objective-c)使用wifi / 3g ip地址检索当前城市名称? - How to retrieve current city name using wifi/3g ip address with iPhone/iOS programming (Objective-c)? 如何使用可达性来查找iPhone设备是否已连接到3G / Wifi - How to find whether iphone device connected to 3G /Wifi using Reachability 在iOS中,如何从Javascript(web)检测设备是通过3G还是Wifi连接? - In iOS, how to detect from Javascript (web) the device is connected via 3G or Wifi? 通过3G和WIFI传输iPhone的不同来源 - different sources for iphone via 3G and WIFI 使用ifconfig检查我是否在本地WiFi或3G上 - Using ifconfig to check whether I'm on local WiFi or 3G 如何检查本地WiFi网络中的设备是否已使用其IP地址连接? - How to check whether a device in local WiFi network is connected or not using it's IP address? 如何在iPhone上识别当前数据网络是Edge还是3G - How to identify whether the current data network is Edge or 3G on iPhone iphone获得3G DNS主机名和IP地址 - iphone get 3G DNS host name and ip address
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM