asp.net getRemoteAddr of and getRemoteHost of

  • 2020-05-19 05:30:44
  • OfStack

getRemoteAddr() : get the client's IP address
getRemoteHost() : gets the name of the client computer and, if that fails, returns the IP address of the client computer

InetAddress ia = InetAddress.getLocalHost();

String iad = ia. getHostAddress (); / / host IP
String ias = ia. getHostName (); / / host name

Could you please tell me that I used the following statement in JSP page:
System.out.println("request.getRemoteAddr(): " + request.getRemoteAddr());
System.out.println("request.getRemoteHost(): " + request.getRemoteHost());
The results are the same (from the LAN trial).
So what's the difference between getRemoteAddr() and getRemoteHost()?

The first one is to get the ip address of the client
The last one is to get the host name of the client
So let's use the first one.

Use request.getRemoteAddr () to get the ip of client with the information

request.getRemoteAddr() has access to the ip, but the video I have is 0:0:0:0:0:0:0:1. Where is the video coming from and how can I interpret it? All right.



This may be because you did not connect to the Internet or the LAN and did not get ip. It may also be because you have a problem with the way you surf the Internet. I once had such a problem, but when you use the LAN in your company to test ip, it will show

---------------------------------------------------------------

How can I get the real ip address in servlet?
If the client comes from a network segment outside the server, request.getRemoteAddr only gets ip of the client gateway (proxy), is there no way to get the real client ip?

When a user USES a proxy or LAN to access your application, you use the request.getRemoteAddr () method to return either the proxy's address or the LAN gateway's address.