Use the CGI variable REMOTE_ADDR (this can also be accessed from PHP and ASP by $_SERVER['REMOTE_ADDR'] and Request.ServerVariables("REMOTE_ADDR") respectively)

Check for an HTTP header "Via" -...