普通获取IP方法:
服务器IP: Request.ServerVariables("LOCAL_ADDR")
浏览器IP: Request.ServerVariables("REMOTE_ADDR")
绕过代理获取真实IP,获得通过代理的连接的浏览器的真实IP:
Function GetIP() '绕过代理获取真实IP
Dim StrIPAddr
If Request.ServerVariables("HTTP_X_FORWARDED_FOR") = "" OR InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), "unknown") > 0 Then
StrIPAddr = Request.ServerVariables("REMOTE_ADDR")
ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",") > 0 Then
StrIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",")-1)
ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";") > 0 Then
StrIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";")-1)
Else
StrIPAddr = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
End If
GetIP = Trim(Mid(StrIPAddr, 1, 30))
End Function
Response.Write "真实IP为:" & getIP()
注意:可能对Vpn加密代理,高匿代理无效!