Print Page | Close Window

IP Address reporting local not internet address

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums
Forum Description: Support forum for Web Wiz Forums application.
URL: https://forums.webwiz.net/forum_posts.asp?TID=20219
Printed Date: 11 April 2026 at 3:02pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: IP Address reporting local not internet address
Posted By: jckruger
Subject: IP Address reporting local not internet address
Date Posted: 08 June 2006 at 2:19am
I have noticed that the IP address that is logged for some of the users of my forum are sometimes reporting as their local IP address when behind a NAT firewall. Is this the function that interrogates the IP address of the PC when posting a message?. This is from functions_common.asp
 
--------------------------------------------%>----------------------------------------------
'******************************************
'***  Get users IP address  ***
'******************************************
Private Function getIP()
 Dim strIPAddr
 'If they are not going through a proxy get the IP address
 If Request.ServerVariables("HTTP_X_FORWARDED_FOR") = "" OR InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), "unknown") > 0 Then
  strIPAddr = Request.ServerVariables("REMOTE_ADDR")
 'If they are going through multiple proxy servers only get the fisrt IP address in the list (,)
 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)
 'If they are going through multiple proxy servers only get the fisrt IP address in the list (;)
 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)
 'Get the browsers IP address not the proxy servers IP
 Else
  strIPAddr = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
 End If
 'Remove all tags in IP string
 strIPAddr =  removeAllTags(strIPAddr)
 'Place the IP address back into the returning function
 getIP = Trim(Mid(strIPAddr, 1, 30))
End Function
--------------------------------------------%>----------------------------------------------
 
In another bit of my code in default.asp I am using:
 
Request.ServerVariables("REMOTE_ADDR") and it is showing the 'Internet' address rather than the local PC ip address and so is showing what I want. This is required if anyone posts bad information I can look up their ISP and take legal action if required.  I have seen some posts to my forum that are showing local 192.xxx.xxx.xxx addresses. Can someone tell me if this is the correct file I should be editing to fix my problem.
 
Cheers
 
Justin



Replies:
Posted By: WebWiz-Bruce
Date Posted: 08 June 2006 at 8:27am
That is the function to change how the IP address is returned.

The problem is if you change it to Request.ServerVariables("REMOTE_ADDR") then you are even less likely to get the correct IP address.

The problem is that IP addresses must be got from the browsers header, which can be changed to hide IP addresses, also if proxy servers, etc. are used then you won't get the IP address using the method you mention.


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net