如何使用php在NAT后面获取IP? [英] how to get ip behind NAT using php?
问题描述
是否可以在PHP中检索NAT后面的IP?
我正在使用$_SERVER["REMOTE_ADDR"]
获取客户端的IP地址.它没有提供位于NAT后面的客户端的确切IP地址.
Is it possible to retrieve IP behind NAT in PHP?
I am using $_SERVER["REMOTE_ADDR"]
for getting IP address of the client. It's not giving exact IP address of the client which is in behind NAT.
推荐答案
否,不可能. NAT表示网络地址转换-数据包的IP地址是在NAT设备上重写的,因此,只要您的服务器知道,公用IP地址就是唯一的IP地址.
Nope, not possible. NAT means Network Address Translation - the IP address of the packets is rewritten at the NAT device, so the public IP address is the only one, as far as your server knows.
但是,您可以使用一些技巧-例如使用Java Applet检查内部IP地址.请参见:从Java applet获取正确的本地IP地址
However, you can employ some tricks - such as checking for the internal IP address using a Java Applet. See this: Get the correct local IP address from java applet
这篇关于如何使用php在NAT后面获取IP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!