Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Request.ServerVariables["REMOTE_ADDR"] reliable enough?

Currently I am using Request.ServerVariables["REMOTE_ADDR"] to get the IP from the client.

What guarantees I get when calling this Method. Or should I look in other ServerVariables as well?

like image 916
Carlos Muñoz Avatar asked Aug 13 '10 22:08

Carlos Muñoz


People also ask

Is Remote_addr reliable?

Yes, it's safe. It is the source IP of the TCP connection and can't be substituted by changing an HTTP header.

What is request ServerVariables Remote_addr?

ServerVariables("REMOTE_ADDR") is Always the Same. If your scripts use Request. ServerVariables("REMOTE_ADDR") to get the client's IP address, they will always show the same, internal IP address due to the load balancers used for hosting your site. You can get the client's remote IP using Request.

What is request ServerVariables Http_x_forwarded_for?

ServerVariables HTTP_X_FORWARDED_FOR is NULL when it is used to fetch the IP Address in ASP.Net using C# and VB.Net.


1 Answers

Found some really neat information on retrieving the client's IP address here.

Essentially, you should probably also pay attention to the Request.ServerVariables("HTTP_X_FORWARDED_FOR") as well. This helps to identify the actual IP address if the end user is going through a proxy whereas the REMOTE_ADDR attribute would be the address of the proxy...unless it is an anonymous proxy in which case, you would still just get the proxy address.

like image 66
Tommy Avatar answered Oct 29 '22 10:10

Tommy