Web Wiz - Green Windows Web Hosting - Celebrating 25 Years!

  New Posts New Posts RSS Feed - IP Address reporting local not internet address
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

IP Address reporting local not internet address

 Post Reply Post Reply
Author
jckruger View Drop Down
Groupie
Groupie
Avatar

Joined: 18 April 2006
Location: Australia
Status: Offline
Points: 135
Post Options Post Options   Thanks (0) Thanks(0)   Quote jckruger Quote  Post ReplyReply Direct Link To This Post Topic: IP Address reporting local not internet address
    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


Edited by jckruger - 08 June 2006 at 2:21am
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.