简体   繁体   中英

How do I find the IP address of a VPN client in PHP

I've been looking around for a while on this issue and after wrestling with my mobile ISP, have finally got a VPN client to test with...

... however ...

All the other solutions using the $_SERVER in this code (great article) seem to only return the IP address of the VPN server address (192.168.1.sss).

My solution requires me to send a message to a remote machine (on the end of a VPN) and not the main VPN server.

For example:

  1. External client browser fills in a form which posts to a PHP page ( VPN:192.168.1.ccc )
  2. The PHP page on server www.example.com (192.168.1.sss) then compiles a suite of instructions to send to the remote machine 192.168.1.rrr on same logical network (through VPN) as server.

... trouble is, $_SERVER[] seems to return 192.168.1.sss rather than 192.168.1.ccc

even if I send a message (using CURL) to 192.168.1.ccc it shows as not found.

any ideas on how to get the VPN client address known to the network in a way that means I can send the message??

Thanks in advance.

I don't think it's possible to retrieve the original client ip in this case. The client isn't given a separate local address, it's tunneling through the vpn gateway. You may be able to forward traffic back to the client through the gateway, depending on your setup. This question has an iptables example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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