Get and print Client's LOCAL IP address with Shell Script - Apache2 CGI/Bin
I've configured Apache2 with the cgi-bin directory so I can run shell scripts from my webserver. I need to figure out a way for the shell script to read the connecting LOCAL ip address (for example 192.168.123.100) of the client, and then print it in the shell script (using echo, I'm guessing).
Here's a sample scenario of what I'd like to have happen.
Client (with local IP of 1开发者_JAVA技巧92.168.123.100) connects to server (some other local IP, for example 192.168.123.122) and client executes the shell script in the cgi-bin directory. The shell script somehow reads the client's local IP address (192.168.123.100), and the prints it in the resulting output.
Is this at all possible?
Thanks for any and all help!
Their IP address should be available in the variable $REMOTE_ADDR
.
In addition to $REMOTE_ADDR you can get many other interesting information. See: http://www.cgi101.com/book/ch3/text.html
Note, that if the client is using proxy or NAT, then you will see only the NAT or proxy server as a remote host.
精彩评论