How to capture local and external IP address from one computer?

I know that it is possible to write local and external ip in java, but I am wondering if it is possible to capture these 2 at the same time or connect the local ip and external ip to the PC that accesses my application.

I am doing a survey form that will be filtered by IP, that is, the user can vote only once. So the idea of ​​capturing an external ip and a local one computer on the local network arose and connected them.

+4
source share
1 answer

To get the IP address, we use the HttpServletRequestobject method getRemoteAddr. But this will only give you the client’s public IP address, especially when the client is behind the proxy server.

String ipAddress = request.getRemoteAddr();

IP- X-FORWARDED-FOR HTTP.

request.getHeader("X-FORWARDED-FOR");

X-FORWARDED-FOR

+2

All Articles