[英]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.