iPad 的绝对 IP 地址?
我有一个 php 页面,学校的学生通过他们的 iPad 登录。我需要在此过程中记录他们的 IP 地址(用于学校的记录保存),但他们都具有与我的方法相同的 IP 地址使用:
if (getenv(HTTP_X_FORWARDED_FOR)) {
$ipaddress = getenv(HTTP_X_FORWARDED_FOR);
} else {
$ipaddress = getenv(REMOTE_ADDR);
}
我可以获得的每台 iPad 独有的更深入的 IP 地址是什么?
I have a php page where students from the school are logging on via their iPads.. I need to log their IP addresses in the process (for record keeping for the school) but they all have the same IP address with the method I'm using:
if (getenv(HTTP_X_FORWARDED_FOR)) {
$ipaddress = getenv(HTTP_X_FORWARDED_FOR);
} else {
$ipaddress = getenv(REMOTE_ADDR);
}
What is a more in depth IP address that I can obtain that would be unique to each iPad?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是网络的现实。您可以获得的唯一经过验证的地址是
$_SERVER['REMOTE-ADDR']
,因为这是 TCP/IP 握手中协商的地址。这个地址可能只是路由器、代理、NAT 设备或其他你无法“看到”的东西的地址。 HTTP 标头中的任何其他内容都是完全无法证明、不可靠且容易被欺骗的。根本无法保证或期望 IP 地址是唯一的或“真实的”,除非您完全控制并完全了解客户端和服务器之间的网络。
这是因为基于 IP 的数据包交换网络旨在将数据从网络上的一个节点可靠地传送到另一个节点。 IP 地址是其实现细节。两者都不是为了唯一识别而设计的。
That's the reality of networking. The only proven address you can get is
$_SERVER['REMOTE-ADDR']
, since that's the one negotiated in the TCP/IP handshake. And this address may just be that of a router, proxy, NAT device or something else which you cannot "see beyond". Anything else in the HTTP headers is completely unprovable, unreliable and easy to spoof.IP addresses simply cannot be guaranteed or expected to be unique or "real", unless you are in full control and have full knowledge of the network between the client and your server.
That's because IP-based, packet switched networks are designed for the purpose of reliably delivering data from one node on the network to another. IP addresses are an implementation detail of that. Neither are designed for the purpose of unique identification.
听起来 iPad 位于 NAT 后面,在这种情况下您将无法获取其内部 IP 地址。即使可以,它也不可能是每台 iPad 所独有的。
Sounds like the iPads are behind a NAT, in which case you're not going to be able to get their internal IP addresses. Even if you could, it wouldn't likely be unique to each iPad.