Operating System - Microsoft
1748201 Members
2957 Online
108759 Solutions
New Discussion юеВ

Re: Get the correct IP address

 
SOLVED
Go to solution
'chris'
Super Advisor

Get the correct IP address

hi

I'm using this code:

<%=Request.ServerVariables("REMOTE_ADDR")%>

in the .asp webpage installed on the WIN2000 webserver to show via browser the internal IP address from the workstations.
Normally works, but the problem is, sometimes it shows proxy IP address instead of the workstation.
Howto solve this problem?
5 REPLIES 5
Nader Qaid A.
Frequent Advisor
Solution

Re: Get the correct IP address

Request.ServerVariables("REMOTE_ADDR") can't give you any "real address",
since no "real address" is ever sent except in INTRANETs.
An IP address is something used at the network layer, and shouldn't really be used by your application. If your application needs to know the identity of the sending machine, then it should use something like X.509 certificates, which are meant to represent identity (an IP address is not).
further more you can try when you are using proxy:
<%
ipaddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
if ipaddress = "" then
ipaddress = Request.ServerVariables("REMOTE_ADDR")
end if
%>

Hope that it solve your issue and doubt.
Regards
Enterprise Servers and Storages Engineer
'chris'
Super Advisor

Re: Get the correct IP address

thx, I've implemented this code to asp website:

<%
ipaddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
if ipaddress = "" then
ipaddress = Request.ServerVariables("REMOTE_ADDR")
end if
%>

but the output is empty.
Nader Qaid A.
Frequent Advisor

Re: Get the correct IP address

>>>>if ipaddress = "" then

put the ip address of the proxy between ""


regards
Enterprise Servers and Storages Engineer
'chris'
Super Advisor

Re: Get the correct IP address

sorry , but I don't understand.
Can you pls post the whole code?
Nader Qaid A.
Frequent Advisor

Re: Get the correct IP address

<%
ipaddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
if ipaddress = "" then <<< add your proxy ip"" here and try
ipaddress = Request.ServerVariables("REMOTE_ADDR")
end if
%>

example :
<%
ipaddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
if ipaddress = "192.168.11.253"
ipaddress = Request.ServerVariables("REMOTE_ADDR")
end if
%>

plz reply the results of the outcomes
Enterprise Servers and Storages Engineer