The simplest use of the following statement:
Ip=request. ServerVariables ("REMOTE_ADDR")
Response. Write (IP)
But this method to the proxy server on the Internet is not allowed, so more comprehensive is the following method:
Copy Code code as follows:
<%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 (IP)
%>