关于asp获取真实IP的问题
本帖最后由 linyutian88 于 2014-03-17 13:53:34 编辑
从网上找了两段代码
function getipadd()
ipadd=Request.ServerVariables("HTTP_X_FORWARDED_FOR")
if ipadd= "" Then ipadd=Request.ServerVariables("REMOTE_ADDR")
getipadd=ipadd
end function
Private function getIP()
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
ip=getIP()
response.Write(getipadd)
response.Write(ip)
但通过ip代理软件之后 获取的是代理ip 并非真实ip 请问各位大侠有什么好的方法吗
------解决方案--------------------就这2个方法,如果获取不到没得办法,就和vpn一样,获取不到真实ip地址
------解决方案--------------------如何获取局域网IP呀?通过这两个好像都是获取的公网IP
------解决方案--------------------其实不建议用HTTP_X_FORWARDED_FOR获取ip,因为这个可以伪造
REMOTE_ADDR虽然不能获得代理后面的ip的,但很难伪造